Mercurial > hg > octave-kai > gnulib-hg
annotate lib/regex_internal.h @ 7733:9d60f39f35c1
* MODULES.html.sh: New module wctype.
* lib/wctype_.h, m4/wctype.m4, modules/wctype: New files.
* lib/fnmatch.c: Don't bother to include <wchar.h> before
<wctype.h>, since the new wctype module should fix this.
* lib/quotearg.c: Include <wctype.h> unconditionally, since
the wctype module should arrange for it.
* lib/regex_internal.h: Likewise.
* m4/quotearg.m4 (gl_QUOTEARG): Don't check for wctype.h or iswprint,
since the wctype module should handle this now.
* m4/regex.m4 (gl_PREREQ_REGEX): Don't check for wctype.h.
* modules/fnmatch (Depends-on): Add wctype.
* modules/quotearg (Depends-on): Likewise.
* modules/regex (Depends-on): Likewise.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 22 Dec 2006 00:21:54 +0000 |
parents | 47b81ff5eb33 |
children | b6376840b47b |
rev | line source |
---|---|
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
1 /* Extended regular expression matching and search library. |
6539
5a1c91276525
* regex_internal.h (BITSET_WORD_BITS):
Paul Eggert <eggert@cs.ucla.edu>
parents:
6296
diff
changeset
|
2 Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
3 This file is part of the GNU C Library. |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
5 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
9 any later version. |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
10 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
14 GNU General Public License for more details. |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
15 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
16 You should have received a copy of the GNU General Public License along |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
17 with this program; if not, write to the Free Software Foundation, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
19 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
20 #ifndef _REGEX_INTERNAL_H |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
21 #define _REGEX_INTERNAL_H 1 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
22 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
23 #include <assert.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
24 #include <ctype.h> |
6195
25eaa608fc4e
Use bool where appropriate.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6184
diff
changeset
|
25 #include <stdbool.h> |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
26 #include <stdio.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
27 #include <stdlib.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
28 #include <string.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
29 |
6275 | 30 #ifndef _LIBC |
31 # include "strcase.h" | |
32 #endif | |
33 | |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
34 #if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
35 # include <langinfo.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
36 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
37 #if defined HAVE_LOCALE_H || defined _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
38 # include <locale.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
39 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
40 #if defined HAVE_WCHAR_H || defined _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
41 # include <wchar.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
42 #endif /* HAVE_WCHAR_H || _LIBC */ |
7733
9d60f39f35c1
* MODULES.html.sh: New module wctype.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7709
diff
changeset
|
43 #include <wctype.h> |
7162
19c2e5121b2f
Add and change modules to make it easier for coreutils to use
Paul Eggert <eggert@cs.ucla.edu>
parents:
7066
diff
changeset
|
44 #include <stdint.h> |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
45 #if defined _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
46 # include <bits/libc-lock.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
47 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
48 # define __libc_lock_init(NAME) do { } while (0) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
49 # define __libc_lock_lock(NAME) do { } while (0) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
50 # define __libc_lock_unlock(NAME) do { } while (0) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
51 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
52 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
53 /* In case that the system doesn't have isblank(). */ |
6932
6aeb4d6c28d9
* lib/.cppi-disable: Add wcwidth.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6726
diff
changeset
|
54 #if !defined _LIBC && !HAVE_DECL_ISBLANK && !defined isblank |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
55 # define isblank(ch) ((ch) == ' ' || (ch) == '\t') |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
56 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
57 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
58 #ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
59 # ifndef _RE_DEFINE_LOCALE_FUNCTIONS |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
60 # define _RE_DEFINE_LOCALE_FUNCTIONS 1 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
61 # include <locale/localeinfo.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
62 # include <locale/elem-hash.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
63 # include <locale/coll-lookup.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
64 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
65 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
66 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
67 /* This is for other GNU distributions with internationalized messages. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
68 #if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
69 # include <libintl.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
70 # ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
71 # undef gettext |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
72 # define gettext(msgid) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
73 INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
74 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
75 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
76 # define gettext(msgid) (msgid) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
77 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
78 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
79 #ifndef gettext_noop |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
80 /* This define is so xgettext can find the internationalizable |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
81 strings. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
82 # define gettext_noop(String) String |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
83 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
84 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
85 /* For loser systems without the definition. */ |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
86 #ifndef SIZE_MAX |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
87 # define SIZE_MAX ((size_t) -1) |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
88 #endif |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
89 |
7709
47b81ff5eb33
* lib/fnmatch.c (WIDE_CHAR_SUPPORT): Require HAVE_ISWCTYPE, too.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7689
diff
changeset
|
90 #if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_ISWCTYPE && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
91 # define RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
92 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
93 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
94 #if __GNUC__ >= 3 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
95 # define BE(expr, val) __builtin_expect (expr, val) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
96 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
97 # define BE(expr, val) (expr) |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
98 # ifdef _LIBC |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
99 # define inline |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
100 # endif |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
101 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
102 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
103 /* Number of ASCII characters. */ |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
104 #define ASCII_CHARS 0x80 |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
105 |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
106 /* Number of single byte characters. */ |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
107 #define SBC_MAX (UCHAR_MAX + 1) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
108 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
109 #define COLL_ELEM_LEN_MAX 8 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
110 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
111 /* The character which represents newline. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
112 #define NEWLINE_CHAR '\n' |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
113 #define WIDE_NEWLINE_CHAR L'\n' |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
114 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
115 /* Rename to standard API for using out of glibc. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
116 #ifndef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
117 # define __wctype wctype |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
118 # define __iswctype iswctype |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
119 # define __btowc btowc |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
120 # ifndef __mempcpy |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
121 # define __mempcpy mempcpy |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
122 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
123 # define __wcrtomb wcrtomb |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
124 # define __regfree regfree |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
125 # define attribute_hidden |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
126 #endif /* not _LIBC */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
127 |
6296
ac6a92dc851d
* regex_internal.h (__GNUC_PREREQ, always_inline, inline, pure):
Paul Eggert <eggert@cs.ucla.edu>
parents:
6294
diff
changeset
|
128 #if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
129 # define __attribute(arg) __attribute__ (arg) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
130 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
131 # define __attribute(arg) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
132 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
133 |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
134 typedef __re_idx_t Idx; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
135 |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
136 /* Special return value for failure to match. */ |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
137 #define REG_MISSING ((Idx) -1) |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
138 |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
139 /* Special return value for internal error. */ |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
140 #define REG_ERROR ((Idx) -2) |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
141 |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
142 /* Test whether N is a valid index, and is not one of the above. */ |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
143 #ifdef _REGEX_LARGE_OFFSETS |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
144 # define REG_VALID_INDEX(n) ((Idx) (n) < REG_ERROR) |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
145 #else |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
146 # define REG_VALID_INDEX(n) (0 <= (n)) |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
147 #endif |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
148 |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
149 /* Test whether N is a valid nonzero index. */ |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
150 #ifdef _REGEX_LARGE_OFFSETS |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
151 # define REG_VALID_NONZERO_INDEX(n) ((Idx) ((n) - 1) < (Idx) (REG_ERROR - 1)) |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
152 #else |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
153 # define REG_VALID_NONZERO_INDEX(n) (0 < (n)) |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
154 #endif |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
155 |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
156 /* A hash value, suitable for computing hash tables. */ |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
157 typedef __re_size_t re_hashval_t; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
158 |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
159 /* An integer used to represent a set of bits. It must be unsigned, |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
160 and must be at least as wide as unsigned int. */ |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
161 typedef unsigned long int bitset_word_t; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
162 /* All bits set in a bitset_word_t. */ |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
163 #define BITSET_WORD_MAX ULONG_MAX |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
164 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
165 /* Number of bits in a bitset_word_t. For portability to hosts with |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
166 padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)'; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
167 instead, deduce it directly from BITSET_WORD_MAX. Avoid |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
168 greater-than-32-bit integers and unconditional shifts by more than |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
169 31 bits, as they're not portable. */ |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
170 #if BITSET_WORD_MAX == 0xffffffff |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
171 # define BITSET_WORD_BITS 32 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
172 #elif BITSET_WORD_MAX >> 31 >> 5 == 1 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
173 # define BITSET_WORD_BITS 36 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
174 #elif BITSET_WORD_MAX >> 31 >> 16 == 1 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
175 # define BITSET_WORD_BITS 48 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
176 #elif BITSET_WORD_MAX >> 31 >> 28 == 1 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
177 # define BITSET_WORD_BITS 60 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
178 #elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
179 # define BITSET_WORD_BITS 64 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
180 #elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
181 # define BITSET_WORD_BITS 72 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
182 #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
183 # define BITSET_WORD_BITS 128 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
184 #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
185 # define BITSET_WORD_BITS 256 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
186 #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
187 # define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */ |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
188 # if BITSET_WORD_BITS <= SBC_MAX |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
189 # error "Invalid SBC_MAX" |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
190 # endif |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
191 #elif BITSET_WORD_MAX == (0xffffffff + 2) * 0xffffffff |
6539
5a1c91276525
* regex_internal.h (BITSET_WORD_BITS):
Paul Eggert <eggert@cs.ucla.edu>
parents:
6296
diff
changeset
|
192 /* Work around a bug in 64-bit PGC (before version 6.1-2), where the |
5a1c91276525
* regex_internal.h (BITSET_WORD_BITS):
Paul Eggert <eggert@cs.ucla.edu>
parents:
6296
diff
changeset
|
193 preprocessor mishandles large unsigned values as if they were signed. */ |
5a1c91276525
* regex_internal.h (BITSET_WORD_BITS):
Paul Eggert <eggert@cs.ucla.edu>
parents:
6296
diff
changeset
|
194 # define BITSET_WORD_BITS 64 |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
195 #else |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
196 # error "Add case for new bitset_word_t size" |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
197 #endif |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
198 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
199 /* Number of bitset_word_t values in a bitset_t. */ |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
200 #define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
201 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
202 typedef bitset_word_t bitset_t[BITSET_WORDS]; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
203 typedef bitset_word_t *re_bitset_ptr_t; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
204 typedef const bitset_word_t *re_const_bitset_ptr_t; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
205 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
206 #define PREV_WORD_CONSTRAINT 0x0001 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
207 #define PREV_NOTWORD_CONSTRAINT 0x0002 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
208 #define NEXT_WORD_CONSTRAINT 0x0004 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
209 #define NEXT_NOTWORD_CONSTRAINT 0x0008 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
210 #define PREV_NEWLINE_CONSTRAINT 0x0010 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
211 #define NEXT_NEWLINE_CONSTRAINT 0x0020 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
212 #define PREV_BEGBUF_CONSTRAINT 0x0040 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
213 #define NEXT_ENDBUF_CONSTRAINT 0x0080 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
214 #define WORD_DELIM_CONSTRAINT 0x0100 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
215 #define NOT_WORD_DELIM_CONSTRAINT 0x0200 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
216 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
217 typedef enum |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
218 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
219 INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
220 WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
221 WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
222 INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
223 LINE_FIRST = PREV_NEWLINE_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
224 LINE_LAST = NEXT_NEWLINE_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
225 BUF_FIRST = PREV_BEGBUF_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
226 BUF_LAST = NEXT_ENDBUF_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
227 WORD_DELIM = WORD_DELIM_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
228 NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
229 } re_context_type; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
230 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
231 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
232 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
233 Idx alloc; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
234 Idx nelem; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
235 Idx *elems; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
236 } re_node_set; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
237 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
238 typedef enum |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
239 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
240 NON_TYPE = 0, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
241 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
242 /* Node type, These are used by token, node, tree. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
243 CHARACTER = 1, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
244 END_OF_RE = 2, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
245 SIMPLE_BRACKET = 3, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
246 OP_BACK_REF = 4, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
247 OP_PERIOD = 5, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
248 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
249 COMPLEX_BRACKET = 6, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
250 OP_UTF8_PERIOD = 7, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
251 #endif /* RE_ENABLE_I18N */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
252 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
253 /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
254 when the debugger shows values of this enum type. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
255 #define EPSILON_BIT 8 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
256 OP_OPEN_SUBEXP = EPSILON_BIT | 0, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
257 OP_CLOSE_SUBEXP = EPSILON_BIT | 1, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
258 OP_ALT = EPSILON_BIT | 2, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
259 OP_DUP_ASTERISK = EPSILON_BIT | 3, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
260 ANCHOR = EPSILON_BIT | 4, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
261 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
262 /* Tree type, these are used only by tree. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
263 CONCAT = 16, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
264 SUBEXP = 17, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
265 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
266 /* Token type, these are used only by token. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
267 OP_DUP_PLUS = 18, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
268 OP_DUP_QUESTION, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
269 OP_OPEN_BRACKET, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
270 OP_CLOSE_BRACKET, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
271 OP_CHARSET_RANGE, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
272 OP_OPEN_DUP_NUM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
273 OP_CLOSE_DUP_NUM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
274 OP_NON_MATCH_LIST, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
275 OP_OPEN_COLL_ELEM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
276 OP_CLOSE_COLL_ELEM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
277 OP_OPEN_EQUIV_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
278 OP_CLOSE_EQUIV_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
279 OP_OPEN_CHAR_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
280 OP_CLOSE_CHAR_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
281 OP_WORD, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
282 OP_NOTWORD, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
283 OP_SPACE, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
284 OP_NOTSPACE, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
285 BACK_SLASH |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
286 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
287 } re_token_type_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
288 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
289 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
290 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
291 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
292 /* Multibyte characters. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
293 wchar_t *mbchars; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
294 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
295 /* Collating symbols. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
296 # ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
297 int32_t *coll_syms; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
298 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
299 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
300 /* Equivalence classes. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
301 # ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
302 int32_t *equiv_classes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
303 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
304 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
305 /* Range expressions. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
306 # ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
307 uint32_t *range_starts; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
308 uint32_t *range_ends; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
309 # else /* not _LIBC */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
310 wchar_t *range_starts; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
311 wchar_t *range_ends; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
312 # endif /* not _LIBC */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
313 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
314 /* Character classes. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
315 wctype_t *char_classes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
316 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
317 /* If this character set is the non-matching list. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
318 unsigned int non_match : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
319 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
320 /* # of multibyte characters. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
321 Idx nmbchars; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
322 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
323 /* # of collating symbols. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
324 Idx ncoll_syms; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
325 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
326 /* # of equivalence classes. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
327 Idx nequiv_classes; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
328 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
329 /* # of range expressions. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
330 Idx nranges; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
331 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
332 /* # of character classes. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
333 Idx nchar_classes; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
334 } re_charset_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
335 #endif /* RE_ENABLE_I18N */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
336 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
337 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
338 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
339 union |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
340 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
341 unsigned char c; /* for CHARACTER */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
342 re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
343 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
344 re_charset_t *mbcset; /* for COMPLEX_BRACKET */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
345 #endif /* RE_ENABLE_I18N */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
346 Idx idx; /* for BACK_REF */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
347 re_context_type ctx_type; /* for ANCHOR */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
348 } opr; |
7689
b4806b1ec9e4
Fix some incompatibilities with gcc -ansi -pedantic.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7162
diff
changeset
|
349 #if __GNUC__ >= 2 && !__STRICT_ANSI__ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
350 re_token_type_t type : 8; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
351 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
352 re_token_type_t type; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
353 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
354 unsigned int constraint : 10; /* context constraint */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
355 unsigned int duplicated : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
356 unsigned int opt_subexp : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
357 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
358 unsigned int accept_mb : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
359 /* These 2 bits can be moved into the union if needed (e.g. if running out |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
360 of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
361 unsigned int mb_partial : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
362 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
363 unsigned int word_char : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
364 } re_token_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
365 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
366 #define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
367 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
368 struct re_string_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
369 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
370 /* Indicate the raw buffer which is the original string passed as an |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
371 argument of regexec(), re_search(), etc.. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
372 const unsigned char *raw_mbs; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
373 /* Store the multibyte string. In case of "case insensitive mode" like |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
374 REG_ICASE, upper cases of the string are stored, otherwise MBS points |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
375 the same address that RAW_MBS points. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
376 unsigned char *mbs; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
377 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
378 /* Store the wide character string which is corresponding to MBS. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
379 wint_t *wcs; |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
380 Idx *offsets; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
381 mbstate_t cur_state; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
382 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
383 /* Index in RAW_MBS. Each character mbs[i] corresponds to |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
384 raw_mbs[raw_mbs_idx + i]. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
385 Idx raw_mbs_idx; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
386 /* The length of the valid characters in the buffers. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
387 Idx valid_len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
388 /* The corresponding number of bytes in raw_mbs array. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
389 Idx valid_raw_len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
390 /* The length of the buffers MBS and WCS. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
391 Idx bufs_len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
392 /* The index in MBS, which is updated by re_string_fetch_byte. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
393 Idx cur_idx; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
394 /* length of RAW_MBS array. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
395 Idx raw_len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
396 /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
397 Idx len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
398 /* End of the buffer may be shorter than its length in the cases such |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
399 as re_match_2, re_search_2. Then, we use STOP for end of the buffer |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
400 instead of LEN. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
401 Idx raw_stop; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
402 /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
403 Idx stop; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
404 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
405 /* The context of mbs[0]. We store the context independently, since |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
406 the context of mbs[0] may be different from raw_mbs[0], which is |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
407 the beginning of the input string. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
408 unsigned int tip_context; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
409 /* The translation passed as a part of an argument of re_compile_pattern. */ |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
410 RE_TRANSLATE_TYPE trans; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
411 /* Copy of re_dfa_t's word_char. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
412 re_const_bitset_ptr_t word_char; |
6195
25eaa608fc4e
Use bool where appropriate.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6184
diff
changeset
|
413 /* true if REG_ICASE. */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
414 unsigned char icase; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
415 unsigned char is_utf8; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
416 unsigned char map_notascii; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
417 unsigned char mbs_allocated; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
418 unsigned char offsets_needed; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
419 unsigned char newline_anchor; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
420 unsigned char word_ops_used; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
421 int mb_cur_max; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
422 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
423 typedef struct re_string_t re_string_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
424 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
425 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
426 struct re_dfa_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
427 typedef struct re_dfa_t re_dfa_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
428 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
429 #ifndef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
430 # ifdef __i386__ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
431 # define internal_function __attribute ((regparm (3), stdcall)) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
432 # else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
433 # define internal_function |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
434 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
435 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
436 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
437 static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
438 Idx new_buf_len) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
439 internal_function; |
6076
e2dd51f6e259
* config/srclist.txt: Add glibc bugs 1220, 1221, 1222.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5968
diff
changeset
|
440 #ifdef RE_ENABLE_I18N |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
441 static void build_wcs_buffer (re_string_t *pstr) internal_function; |
6119
c3bf2ea44695
Make regex safe for g++. This fixes one real bug (an "err"
Paul Eggert <eggert@cs.ucla.edu>
parents:
6101
diff
changeset
|
442 static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr) |
c3bf2ea44695
Make regex safe for g++. This fixes one real bug (an "err"
Paul Eggert <eggert@cs.ucla.edu>
parents:
6101
diff
changeset
|
443 internal_function; |
6076
e2dd51f6e259
* config/srclist.txt: Add glibc bugs 1220, 1221, 1222.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5968
diff
changeset
|
444 #endif /* RE_ENABLE_I18N */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
445 static void build_upper_buffer (re_string_t *pstr) internal_function; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
446 static void re_string_translate_buffer (re_string_t *pstr) internal_function; |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
447 static unsigned int re_string_context_at (const re_string_t *input, Idx idx, |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
448 int eflags) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
449 internal_function __attribute ((pure)); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
450 #define re_string_peek_byte(pstr, offset) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
451 ((pstr)->mbs[(pstr)->cur_idx + offset]) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
452 #define re_string_fetch_byte(pstr) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
453 ((pstr)->mbs[(pstr)->cur_idx++]) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
454 #define re_string_first_byte(pstr, idx) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
455 ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
456 #define re_string_is_single_byte_char(pstr, idx) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
457 ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
458 || (pstr)->wcs[(idx) + 1] != WEOF)) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
459 #define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
460 #define re_string_cur_idx(pstr) ((pstr)->cur_idx) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
461 #define re_string_get_buffer(pstr) ((pstr)->mbs) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
462 #define re_string_length(pstr) ((pstr)->len) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
463 #define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx]) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
464 #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
465 #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
466 |
6125
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
467 #include <alloca.h> |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
468 |
6126
3690c96b6da9
Fix typo: __LIBC -> _LIBC.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6125
diff
changeset
|
469 #ifndef _LIBC |
6125
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
470 # if HAVE_ALLOCA |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
471 /* The OS usually guarantees only one guard page at the bottom of the stack, |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
472 and a page size can be as small as 4096 bytes. So we cannot safely |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
473 allocate anything larger than 4096 bytes. Also care for the possibility |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
474 of a few compiler-allocated temporary stack slots. */ |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
475 # define __libc_use_alloca(n) ((n) < 4032) |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
476 # else |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
477 /* alloca is implemented with malloc, so just use malloc. */ |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
478 # define __libc_use_alloca(n) 0 |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
479 # endif |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
480 #endif |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
481 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
482 #ifndef MAX |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
483 # define MAX(a,b) ((a) < (b) ? (b) : (a)) |
6206
ca2f5d46eeb6
Check for arithmetic overflow when calculating sizes, to prevent
Paul Eggert <eggert@cs.ucla.edu>
parents:
6195
diff
changeset
|
484 #endif |
ca2f5d46eeb6
Check for arithmetic overflow when calculating sizes, to prevent
Paul Eggert <eggert@cs.ucla.edu>
parents:
6195
diff
changeset
|
485 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
486 #define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
487 #define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
488 #define re_free(p) free (p) |
6206
ca2f5d46eeb6
Check for arithmetic overflow when calculating sizes, to prevent
Paul Eggert <eggert@cs.ucla.edu>
parents:
6195
diff
changeset
|
489 |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
490 struct bin_tree_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
491 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
492 struct bin_tree_t *parent; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
493 struct bin_tree_t *left; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
494 struct bin_tree_t *right; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
495 struct bin_tree_t *first; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
496 struct bin_tree_t *next; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
497 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
498 re_token_t token; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
499 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
500 /* `node_idx' is the index in dfa->nodes, if `type' == 0. |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
501 Otherwise `type' indicate the type of this node. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
502 Idx node_idx; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
503 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
504 typedef struct bin_tree_t bin_tree_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
505 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
506 #define BIN_TREE_STORAGE_SIZE \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
507 ((1024 - sizeof (void *)) / sizeof (bin_tree_t)) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
508 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
509 struct bin_tree_storage_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
510 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
511 struct bin_tree_storage_t *next; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
512 bin_tree_t data[BIN_TREE_STORAGE_SIZE]; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
513 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
514 typedef struct bin_tree_storage_t bin_tree_storage_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
515 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
516 #define CONTEXT_WORD 1 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
517 #define CONTEXT_NEWLINE (CONTEXT_WORD << 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
518 #define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
519 #define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
520 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
521 #define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
522 #define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
523 #define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
524 #define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
525 #define IS_ORDINARY_CONTEXT(c) ((c) == 0) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
526 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
527 #define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_') |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
528 #define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
529 #define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_') |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
530 #define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
531 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
532 #define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
533 ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
534 || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
535 || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
536 || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context))) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
537 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
538 #define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
539 ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
540 || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
541 || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
542 || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context))) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
543 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
544 struct re_dfastate_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
545 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
546 re_hashval_t hash; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
547 re_node_set nodes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
548 re_node_set non_eps_nodes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
549 re_node_set inveclosure; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
550 re_node_set *entrance_nodes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
551 struct re_dfastate_t **trtable, **word_trtable; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
552 unsigned int context : 4; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
553 unsigned int halt : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
554 /* If this state can accept `multi byte'. |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
555 Note that we refer to multibyte characters, and multi character |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
556 collating elements as `multi byte'. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
557 unsigned int accept_mb : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
558 /* If this state has backreference node(s). */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
559 unsigned int has_backref : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
560 unsigned int has_constraint : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
561 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
562 typedef struct re_dfastate_t re_dfastate_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
563 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
564 struct re_state_table_entry |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
565 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
566 Idx num; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
567 Idx alloc; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
568 re_dfastate_t **array; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
569 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
570 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
571 /* Array type used in re_sub_match_last_t and re_sub_match_top_t. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
572 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
573 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
574 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
575 Idx next_idx; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
576 Idx alloc; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
577 re_dfastate_t **array; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
578 } state_array_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
579 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
580 /* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
581 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
582 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
583 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
584 Idx node; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
585 Idx str_idx; /* The position NODE match at. */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
586 state_array_t path; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
587 } re_sub_match_last_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
588 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
589 /* Store information about the node NODE whose type is OP_OPEN_SUBEXP. |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
590 And information about the node, whose type is OP_CLOSE_SUBEXP, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
591 corresponding to NODE is stored in LASTS. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
592 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
593 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
594 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
595 Idx str_idx; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
596 Idx node; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
597 state_array_t *path; |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
598 Idx alasts; /* Allocation size of LASTS. */ |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
599 Idx nlasts; /* The number of LASTS. */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
600 re_sub_match_last_t **lasts; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
601 } re_sub_match_top_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
602 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
603 struct re_backref_cache_entry |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
604 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
605 Idx node; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
606 Idx str_idx; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
607 Idx subexp_from; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
608 Idx subexp_to; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
609 char more; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
610 char unused; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
611 unsigned short int eps_reachable_subexps_map; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
612 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
613 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
614 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
615 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
616 /* The string object corresponding to the input string. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
617 re_string_t input; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
618 #if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
619 const re_dfa_t *const dfa; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
620 #else |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
621 const re_dfa_t *dfa; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
622 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
623 /* EFLAGS of the argument of regexec. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
624 int eflags; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
625 /* Where the matching ends. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
626 Idx match_last; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
627 Idx last_node; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
628 /* The state log used by the matcher. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
629 re_dfastate_t **state_log; |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
630 Idx state_log_top; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
631 /* Back reference cache. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
632 Idx nbkref_ents; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
633 Idx abkref_ents; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
634 struct re_backref_cache_entry *bkref_ents; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
635 int max_mb_elem_len; |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
636 Idx nsub_tops; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
637 Idx asub_tops; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
638 re_sub_match_top_t **sub_tops; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
639 } re_match_context_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
640 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
641 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
642 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
643 re_dfastate_t **sifted_states; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
644 re_dfastate_t **limited_states; |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
645 Idx last_node; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
646 Idx last_str_idx; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
647 re_node_set limits; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
648 } re_sift_context_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
649 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
650 struct re_fail_stack_ent_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
651 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
652 Idx idx; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
653 Idx node; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
654 regmatch_t *regs; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
655 re_node_set eps_via_nodes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
656 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
657 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
658 struct re_fail_stack_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
659 { |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
660 Idx num; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
661 Idx alloc; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
662 struct re_fail_stack_ent_t *stack; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
663 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
664 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
665 struct re_dfa_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
666 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
667 re_token_t *nodes; |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
668 size_t nodes_alloc; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
669 size_t nodes_len; |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
670 Idx *nexts; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
671 Idx *org_indices; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
672 re_node_set *edests; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
673 re_node_set *eclosures; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
674 re_node_set *inveclosures; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
675 struct re_state_table_entry *state_table; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
676 re_dfastate_t *init_state; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
677 re_dfastate_t *init_state_word; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
678 re_dfastate_t *init_state_nl; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
679 re_dfastate_t *init_state_begbuf; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
680 bin_tree_t *str_tree; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
681 bin_tree_storage_t *str_tree_storage; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
682 re_bitset_ptr_t sb_char; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
683 int str_tree_storage_idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
684 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
685 /* number of subexpressions `re_nsub' is in regex_t. */ |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
686 re_hashval_t state_hash_mask; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
687 Idx init_node; |
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
688 Idx nbackref; /* The number of backreference in this dfa. */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
689 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
690 /* Bitmap expressing which backreference is used. */ |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
691 bitset_word_t used_bkref_map; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
692 bitset_word_t completed_bkref_map; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
693 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
694 unsigned int has_plural_match : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
695 /* If this dfa has "multibyte node", which is a backreference or |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
696 a node which can accept multibyte character or multi character |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
697 collating element. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
698 unsigned int has_mb_node : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
699 unsigned int is_utf8 : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
700 unsigned int map_notascii : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
701 unsigned int word_ops_used : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
702 int mb_cur_max; |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
703 bitset_t word_char; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
704 reg_syntax_t syntax; |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
705 Idx *subexp_map; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
706 #ifdef DEBUG |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
707 char* re_str; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
708 #endif |
7066
3288bb324a28
* regex_internal.h (struct re_dfa_t) [!_LIBC]: Avoid invalid C89
Eric Blake <ebb9@byu.net>
parents:
6932
diff
changeset
|
709 #ifdef _LIBC |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
710 __libc_lock_define (, lock) |
7066
3288bb324a28
* regex_internal.h (struct re_dfa_t) [!_LIBC]: Avoid invalid C89
Eric Blake <ebb9@byu.net>
parents:
6932
diff
changeset
|
711 #endif |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
712 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
713 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
714 #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
715 #define re_node_set_remove(set,id) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
716 (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1)) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
717 #define re_node_set_empty(p) ((p)->nelem = 0) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
718 #define re_node_set_free(set) re_free ((set)->elems) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
719 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
720 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
721 typedef enum |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
722 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
723 SB_CHAR, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
724 MB_CHAR, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
725 EQUIV_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
726 COLL_SYM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
727 CHAR_CLASS |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
728 } bracket_elem_type; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
729 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
730 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
731 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
732 bracket_elem_type type; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
733 union |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
734 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
735 unsigned char ch; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
736 unsigned char *name; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
737 wchar_t wch; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
738 } opr; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
739 } bracket_elem_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
740 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
741 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
742 /* Inline functions for bitset_t operation. */ |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
743 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
744 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
745 bitset_set (bitset_t set, Idx i) |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
746 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
747 set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS; |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
748 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
749 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
750 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
751 bitset_clear (bitset_t set, Idx i) |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
752 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
753 set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS); |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
754 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
755 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
756 static inline bool |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
757 bitset_contain (const bitset_t set, Idx i) |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
758 { |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
759 return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1; |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
760 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
761 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
762 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
763 bitset_empty (bitset_t set) |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
764 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
765 memset (set, '\0', sizeof (bitset_t)); |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
766 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
767 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
768 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
769 bitset_set_all (bitset_t set) |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
770 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
771 memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS)); |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
772 if (SBC_MAX % BITSET_WORD_BITS != 0) |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
773 set[BITSET_WORDS - 1] = |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
774 ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1; |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
775 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
776 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
777 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
778 bitset_copy (bitset_t dest, const bitset_t src) |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
779 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
780 memcpy (dest, src, sizeof (bitset_t)); |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
781 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
782 |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
783 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
784 bitset_not (bitset_t set) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
785 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
786 int bitset_i; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
787 for (bitset_i = 0; bitset_i < SBC_MAX / BITSET_WORD_BITS; ++bitset_i) |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
788 set[bitset_i] = ~set[bitset_i]; |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
789 if (SBC_MAX % BITSET_WORD_BITS != 0) |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
790 set[BITSET_WORDS - 1] = |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
791 ((((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1) |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
792 & ~set[BITSET_WORDS - 1]); |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
793 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
794 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
795 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
796 bitset_merge (bitset_t dest, const bitset_t src) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
797 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
798 int bitset_i; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
799 for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
800 dest[bitset_i] |= src[bitset_i]; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
801 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
802 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
803 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
804 bitset_mask (bitset_t dest, const bitset_t src) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
805 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
806 int bitset_i; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
807 for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
808 dest[bitset_i] &= src[bitset_i]; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
809 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
810 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
811 #ifdef RE_ENABLE_I18N |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
812 /* Inline functions for re_string. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
813 static inline int |
6129
2fce0cb93f59
* config/srclist.text: Add glibc bug 1248.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6126
diff
changeset
|
814 internal_function __attribute ((pure)) |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
815 re_string_char_size_at (const re_string_t *pstr, Idx idx) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
816 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
817 int byte_idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
818 if (pstr->mb_cur_max == 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
819 return 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
820 for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
821 if (pstr->wcs[idx + byte_idx] != WEOF) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
822 break; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
823 return byte_idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
824 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
825 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
826 static inline wint_t |
6129
2fce0cb93f59
* config/srclist.text: Add glibc bug 1248.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6126
diff
changeset
|
827 internal_function __attribute ((pure)) |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
828 re_string_wchar_at (const re_string_t *pstr, Idx idx) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
829 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
830 if (pstr->mb_cur_max == 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
831 return (wint_t) pstr->mbs[idx]; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
832 return (wint_t) pstr->wcs[idx]; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
833 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
834 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
835 static int |
6129
2fce0cb93f59
* config/srclist.text: Add glibc bug 1248.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6126
diff
changeset
|
836 internal_function __attribute ((pure)) |
6184
f1728546eca4
On 64-bit hosts (where size_t is 64 bits and int is 32 bits), the
Paul Eggert <eggert@cs.ucla.edu>
parents:
6171
diff
changeset
|
837 re_string_elem_size_at (const re_string_t *pstr, Idx idx) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
838 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
839 # ifdef _LIBC |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
840 const unsigned char *p, *extra; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
841 const int32_t *table, *indirect; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
842 int32_t tmp; |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
843 # include <locale/weight.h> |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
844 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
845 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
846 if (nrules != 0) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
847 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
848 table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
849 extra = (const unsigned char *) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
850 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
851 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
852 _NL_COLLATE_INDIRECTMB); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
853 p = pstr->mbs + idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
854 tmp = findidx (&p); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
855 return p - pstr->mbs - idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
856 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
857 else |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
858 # endif /* _LIBC */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
859 return 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
860 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
861 #endif /* RE_ENABLE_I18N */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
862 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
863 #endif /* _REGEX_INTERNAL_H */ |