Mercurial > hg > octave-jordi > gnulib-hg
annotate lib/regex_internal.h @ 15523:705e7cdfdeaf
regex: port to Stratus OpenVOS
* lib/regex_internal.h (internal_function) [!_LIBC]: Simply
define to empty, rather than attempting nonportable optimizations.
Problem reported by Paul Green in:
http://lists.gnu.org/archive/html/bug-diffutils/2011-08/msg00047.html
and fix suggested by Eric Blake in:
http://lists.gnu.org/archive/html/bug-gnulib/2011-08/msg00143.html
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 18 Aug 2011 00:46:17 -0700 |
parents | cd4635d4dbe6 |
children | cfa1d5dbe78c |
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. |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
13367
diff
changeset
|
2 Copyright (C) 2002-2011 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 |
12567
ceb1562f60a5
regcomp: sync from glibc; always use nl_langinfo
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
30 #include <langinfo.h> |
ceb1562f60a5
regcomp: sync from glibc; always use nl_langinfo
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
31 #ifndef _LIBC |
8153
0f48fdcc7a64
Fix regex code so it doesn't rely on strcasecmp.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8073
diff
changeset
|
32 # include "localcharset.h" |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
33 #endif |
14186
cd4635d4dbe6
assume <ctype.h>, ..., <time.h> exist
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
34 #include <locale.h> |
7888
b6376840b47b
* modules/fnmatch (Depends-on): Depend on wchar.
Eric Blake <ebb9@byu.net>
parents:
7733
diff
changeset
|
35 |
b6376840b47b
* modules/fnmatch (Depends-on): Depend on wchar.
Eric Blake <ebb9@byu.net>
parents:
7733
diff
changeset
|
36 #include <wchar.h> |
7733
9d60f39f35c1
* MODULES.html.sh: New module wctype.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7709
diff
changeset
|
37 #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
|
38 #include <stdint.h> |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
39 #if defined _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
40 # include <bits/libc-lock.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
41 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
42 # 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
|
43 # 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
|
44 # 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
|
45 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
46 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
47 /* In case that the system doesn't have isblank(). */ |
8921
28ffab893f7a
Work around problem reported by Steven M. Schweda in
Paul Eggert <eggert@cs.ucla.edu>
parents:
8153
diff
changeset
|
48 #if !defined _LIBC && ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK)) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
49 # define isblank(ch) ((ch) == ' ' || (ch) == '\t') |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
50 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
51 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
52 #ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
53 # ifndef _RE_DEFINE_LOCALE_FUNCTIONS |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
54 # define _RE_DEFINE_LOCALE_FUNCTIONS 1 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
55 # include <locale/localeinfo.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
56 # include <locale/elem-hash.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
57 # include <locale/coll-lookup.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
58 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
59 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
60 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
61 /* 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
|
62 #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
|
63 # include <libintl.h> |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
64 # ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
65 # undef gettext |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
66 # define gettext(msgid) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
67 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
|
68 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
69 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
70 # define gettext(msgid) (msgid) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
71 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
72 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
73 #ifndef gettext_noop |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
74 /* 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
|
75 strings. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
76 # define gettext_noop(String) String |
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 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
79 /* 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
|
80 #ifndef SIZE_MAX |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
81 # 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
|
82 #endif |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
83 |
14186
cd4635d4dbe6
assume <ctype.h>, ..., <time.h> exist
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
84 #if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
85 # define RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
86 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
87 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
88 #if __GNUC__ >= 3 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
89 # 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
|
90 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
91 # 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
|
92 # ifdef _LIBC |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
93 # define inline |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
94 # endif |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
95 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
96 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
97 /* Number of ASCII characters. */ |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
98 #define ASCII_CHARS 0x80 |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
99 |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
100 /* 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
|
101 #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
|
102 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
103 #define COLL_ELEM_LEN_MAX 8 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
104 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
105 /* The character which represents newline. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
106 #define NEWLINE_CHAR '\n' |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
107 #define WIDE_NEWLINE_CHAR L'\n' |
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 /* 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
|
110 #ifndef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
111 # define __wctype wctype |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
112 # define __iswctype iswctype |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
113 # define __btowc btowc |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
114 # define __wcrtomb wcrtomb |
10998
cc7a1af3872f
regex: replace mbrtowc with __mbrtowc.
Paolo Bonzini <bonzini@gnu.org>
parents:
10952
diff
changeset
|
115 # define __mbrtowc mbrtowc |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
116 # define __regfree regfree |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
117 # define attribute_hidden |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
118 #endif /* not _LIBC */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
119 |
6296
ac6a92dc851d
* regex_internal.h (__GNUC_PREREQ, always_inline, inline, pure):
Paul Eggert <eggert@cs.ucla.edu>
parents:
6294
diff
changeset
|
120 #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
|
121 # define __attribute(arg) __attribute__ (arg) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
122 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
123 # define __attribute(arg) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
124 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
125 |
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
|
126 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
|
127 |
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
|
128 /* 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
|
129 #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
|
130 |
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
|
131 /* 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
|
132 #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
|
133 |
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 /* 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
|
135 #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
|
136 # 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
|
137 #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
|
138 # 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
|
139 #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
|
140 |
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 /* 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
|
142 #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
|
143 # 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
|
144 #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
|
145 # 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
|
146 #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
|
147 |
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 /* 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
|
149 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
|
150 |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
151 /* 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
|
152 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
|
153 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
|
154 /* 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
|
155 #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
|
156 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
157 /* 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
|
158 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
|
159 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
|
160 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
|
161 31 bits, as they're not portable. */ |
10294
8fd1a5ad043a
Make determination of BITSET_WORD_MAX work also with old HP-UX cc compilers.
Bruno Haible <bruno@clisp.org>
parents:
9890
diff
changeset
|
162 #if BITSET_WORD_MAX == 0xffffffffUL |
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_BITS 32 |
10294
8fd1a5ad043a
Make determination of BITSET_WORD_MAX work also with old HP-UX cc compilers.
Bruno Haible <bruno@clisp.org>
parents:
9890
diff
changeset
|
164 #elif BITSET_WORD_MAX >> 31 >> 4 == 1 |
6214
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
165 # 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
|
166 #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
|
167 # 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
|
168 #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
|
169 # 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
|
170 #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
|
171 # 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
|
172 #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
|
173 # 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
|
174 #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
|
175 # 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
|
176 #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
|
177 # 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
|
178 #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
|
179 # 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
|
180 # 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
|
181 # 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
|
182 # endif |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
183 #else |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
184 # 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
|
185 #endif |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
186 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
187 /* 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
|
188 #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
|
189 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
194 #define PREV_WORD_CONSTRAINT 0x0001 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
195 #define PREV_NOTWORD_CONSTRAINT 0x0002 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
196 #define NEXT_WORD_CONSTRAINT 0x0004 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
197 #define NEXT_NOTWORD_CONSTRAINT 0x0008 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
198 #define PREV_NEWLINE_CONSTRAINT 0x0010 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
199 #define NEXT_NEWLINE_CONSTRAINT 0x0020 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
200 #define PREV_BEGBUF_CONSTRAINT 0x0040 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
201 #define NEXT_ENDBUF_CONSTRAINT 0x0080 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
202 #define WORD_DELIM_CONSTRAINT 0x0100 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
203 #define NOT_WORD_DELIM_CONSTRAINT 0x0200 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
204 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
205 typedef enum |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
206 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
207 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
|
208 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
|
209 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
|
210 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
|
211 LINE_FIRST = PREV_NEWLINE_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
212 LINE_LAST = NEXT_NEWLINE_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
213 BUF_FIRST = PREV_BEGBUF_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
214 BUF_LAST = NEXT_ENDBUF_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
215 WORD_DELIM = WORD_DELIM_CONSTRAINT, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
216 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
|
217 } re_context_type; |
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 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
220 { |
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
|
221 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
|
222 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
|
223 Idx *elems; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
224 } re_node_set; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
225 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
226 typedef enum |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
227 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
228 NON_TYPE = 0, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
229 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
230 /* 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
|
231 CHARACTER = 1, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
232 END_OF_RE = 2, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
233 SIMPLE_BRACKET = 3, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
234 OP_BACK_REF = 4, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
235 OP_PERIOD = 5, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
236 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
237 COMPLEX_BRACKET = 6, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
238 OP_UTF8_PERIOD = 7, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
239 #endif /* RE_ENABLE_I18N */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
240 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
241 /* 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
|
242 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
|
243 #define EPSILON_BIT 8 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
244 OP_OPEN_SUBEXP = EPSILON_BIT | 0, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
245 OP_CLOSE_SUBEXP = EPSILON_BIT | 1, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
246 OP_ALT = EPSILON_BIT | 2, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
247 OP_DUP_ASTERISK = EPSILON_BIT | 3, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
248 ANCHOR = EPSILON_BIT | 4, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
249 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
250 /* 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
|
251 CONCAT = 16, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
252 SUBEXP = 17, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
253 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
254 /* 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
|
255 OP_DUP_PLUS = 18, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
256 OP_DUP_QUESTION, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
257 OP_OPEN_BRACKET, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
258 OP_CLOSE_BRACKET, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
259 OP_CHARSET_RANGE, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
260 OP_OPEN_DUP_NUM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
261 OP_CLOSE_DUP_NUM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
262 OP_NON_MATCH_LIST, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
263 OP_OPEN_COLL_ELEM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
264 OP_CLOSE_COLL_ELEM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
265 OP_OPEN_EQUIV_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
266 OP_CLOSE_EQUIV_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
267 OP_OPEN_CHAR_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
268 OP_CLOSE_CHAR_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
269 OP_WORD, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
270 OP_NOTWORD, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
271 OP_SPACE, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
272 OP_NOTSPACE, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
273 BACK_SLASH |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
274 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
275 } re_token_type_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
276 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
277 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
278 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
279 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
280 /* Multibyte characters. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
281 wchar_t *mbchars; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
282 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
283 /* Collating symbols. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
284 # ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
285 int32_t *coll_syms; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
286 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
287 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
288 /* Equivalence classes. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
289 # ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
290 int32_t *equiv_classes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
291 # endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
292 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
293 /* Range expressions. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
294 # ifdef _LIBC |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
295 uint32_t *range_starts; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
296 uint32_t *range_ends; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
297 # else /* not _LIBC */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
298 wchar_t *range_starts; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
299 wchar_t *range_ends; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
300 # endif /* not _LIBC */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
301 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
302 /* Character classes. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
303 wctype_t *char_classes; |
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 /* 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
|
306 unsigned int non_match : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
307 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
308 /* # 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
|
309 Idx nmbchars; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
310 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
311 /* # 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
|
312 Idx ncoll_syms; |
5968
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 /* # 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
|
315 Idx nequiv_classes; |
5968
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 /* # 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
|
318 Idx nranges; |
5968
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 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
|
321 Idx nchar_classes; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
322 } re_charset_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
323 #endif /* RE_ENABLE_I18N */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
324 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
325 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
326 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
327 union |
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 unsigned char c; /* for CHARACTER */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
330 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
|
331 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
332 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
|
333 #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
|
334 Idx idx; /* for BACK_REF */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
335 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
|
336 } opr; |
7689
b4806b1ec9e4
Fix some incompatibilities with gcc -ansi -pedantic.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7162
diff
changeset
|
337 #if __GNUC__ >= 2 && !__STRICT_ANSI__ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
338 re_token_type_t type : 8; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
339 #else |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
340 re_token_type_t type; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
341 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
342 unsigned int constraint : 10; /* context constraint */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
343 unsigned int duplicated : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
344 unsigned int opt_subexp : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
345 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
346 unsigned int accept_mb : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
347 /* 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
|
348 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
|
349 unsigned int mb_partial : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
350 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
351 unsigned int word_char : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
352 } re_token_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
353 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
354 #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
|
355 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
356 struct re_string_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
357 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
358 /* 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
|
359 argument of regexec(), re_search(), etc.. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
360 const unsigned char *raw_mbs; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
361 /* 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
|
362 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
|
363 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
|
364 unsigned char *mbs; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
365 #ifdef RE_ENABLE_I18N |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
366 /* 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
|
367 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
|
368 Idx *offsets; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
369 mbstate_t cur_state; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
370 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
371 /* 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
|
372 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
|
373 Idx raw_mbs_idx; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
374 /* 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
|
375 Idx valid_len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
376 /* 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
|
377 Idx valid_raw_len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
378 /* 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
|
379 Idx bufs_len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
380 /* 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
|
381 Idx cur_idx; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
382 /* 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
|
383 Idx raw_len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
384 /* 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
|
385 Idx len; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
386 /* 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
|
387 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
|
388 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
|
389 Idx raw_stop; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
390 /* 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
|
391 Idx stop; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
392 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
393 /* 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
|
394 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
|
395 the beginning of the input string. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
396 unsigned int tip_context; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
397 /* 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
|
398 RE_TRANSLATE_TYPE trans; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
399 /* 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
|
400 re_const_bitset_ptr_t word_char; |
6195
25eaa608fc4e
Use bool where appropriate.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6184
diff
changeset
|
401 /* true if REG_ICASE. */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
402 unsigned char icase; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
403 unsigned char is_utf8; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
404 unsigned char map_notascii; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
405 unsigned char mbs_allocated; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
406 unsigned char offsets_needed; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
407 unsigned char newline_anchor; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
408 unsigned char word_ops_used; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
409 int mb_cur_max; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
410 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
411 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
|
412 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
413 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
414 struct re_dfa_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
415 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
|
416 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
417 #ifndef _LIBC |
15523
705e7cdfdeaf
regex: port to Stratus OpenVOS
Paul Eggert <eggert@cs.ucla.edu>
parents:
14186
diff
changeset
|
418 # define internal_function |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
419 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
420 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
421 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
|
422 Idx new_buf_len) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
423 internal_function; |
6076
e2dd51f6e259
* config/srclist.txt: Add glibc bugs 1220, 1221, 1222.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5968
diff
changeset
|
424 #ifdef RE_ENABLE_I18N |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
425 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
|
426 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
|
427 internal_function; |
6076
e2dd51f6e259
* config/srclist.txt: Add glibc bugs 1220, 1221, 1222.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5968
diff
changeset
|
428 #endif /* RE_ENABLE_I18N */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
429 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
|
430 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
|
431 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
|
432 int eflags) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
433 internal_function __attribute ((pure)); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
434 #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
|
435 ((pstr)->mbs[(pstr)->cur_idx + offset]) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
436 #define re_string_fetch_byte(pstr) \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
437 ((pstr)->mbs[(pstr)->cur_idx++]) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
438 #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
|
439 ((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
|
440 #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
|
441 ((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
|
442 || (pstr)->wcs[(idx) + 1] != WEOF)) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
443 #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
|
444 #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
|
445 #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
|
446 #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
|
447 #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
|
448 #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
|
449 #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
|
450 |
6125
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
451 #include <alloca.h> |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
452 |
6126
3690c96b6da9
Fix typo: __LIBC -> _LIBC.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6125
diff
changeset
|
453 #ifndef _LIBC |
6125
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
454 # if HAVE_ALLOCA |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
455 /* 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
|
456 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
|
457 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
|
458 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
|
459 # 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
|
460 # else |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
461 /* 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
|
462 # define __libc_use_alloca(n) 0 |
13367
df004f9880d2
regex: Don't require alloca.
Bruno Haible <bruno@clisp.org>
parents:
12835
diff
changeset
|
463 # undef alloca |
df004f9880d2
regex: Don't require alloca.
Bruno Haible <bruno@clisp.org>
parents:
12835
diff
changeset
|
464 # define alloca(n) malloc (n) |
6125
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
465 # endif |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
466 #endif |
4af02335816a
* config/srclist.txt: Add glibc bug 1245.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6119
diff
changeset
|
467 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
468 #ifndef MAX |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
469 # 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
|
470 #endif |
ca2f5d46eeb6
Check for arithmetic overflow when calculating sizes, to prevent
Paul Eggert <eggert@cs.ucla.edu>
parents:
6195
diff
changeset
|
471 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
472 #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
|
473 #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
|
474 #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
|
475 |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
476 struct bin_tree_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
477 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
478 struct bin_tree_t *parent; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
479 struct bin_tree_t *left; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
480 struct bin_tree_t *right; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
481 struct bin_tree_t *first; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
482 struct bin_tree_t *next; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
483 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
484 re_token_t token; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
485 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
486 /* `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
|
487 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
|
488 Idx node_idx; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
489 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
490 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
|
491 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
492 #define BIN_TREE_STORAGE_SIZE \ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
493 ((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
|
494 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
495 struct bin_tree_storage_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
496 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
497 struct bin_tree_storage_t *next; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
498 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
|
499 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
500 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
|
501 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
502 #define CONTEXT_WORD 1 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
503 #define CONTEXT_NEWLINE (CONTEXT_WORD << 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
504 #define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
505 #define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
506 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
507 #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
|
508 #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
|
509 #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
|
510 #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
|
511 #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
|
512 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
513 #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
|
514 #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
|
515 #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
|
516 #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
|
517 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
518 #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
|
519 ((((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
|
520 || ((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
|
521 || ((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
|
522 || ((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
|
523 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
524 #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
|
525 ((((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
|
526 || (((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
|
527 || (((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
|
528 || (((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
|
529 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
530 struct re_dfastate_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
531 { |
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
|
532 re_hashval_t hash; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
533 re_node_set nodes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
534 re_node_set non_eps_nodes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
535 re_node_set inveclosure; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
536 re_node_set *entrance_nodes; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
537 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
|
538 unsigned int context : 4; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
539 unsigned int halt : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
540 /* 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
|
541 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
|
542 collating elements as `multi byte'. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
543 unsigned int accept_mb : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
544 /* 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
|
545 unsigned int has_backref : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
546 unsigned int has_constraint : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
547 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
548 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
|
549 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
550 struct re_state_table_entry |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
551 { |
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
|
552 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
|
553 Idx alloc; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
554 re_dfastate_t **array; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
555 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
556 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
557 /* 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
|
558 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
559 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
560 { |
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
|
561 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
|
562 Idx alloc; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
563 re_dfastate_t **array; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
564 } state_array_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
565 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
566 /* 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
|
567 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
568 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
569 { |
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
|
570 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
|
571 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
|
572 state_array_t path; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
573 } re_sub_match_last_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
574 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
575 /* 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
|
576 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
|
577 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
|
578 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
579 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
580 { |
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
|
581 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
|
582 Idx node; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
583 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
|
584 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
|
585 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
|
586 re_sub_match_last_t **lasts; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
587 } re_sub_match_top_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 struct re_backref_cache_entry |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
590 { |
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
|
591 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
|
592 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
|
593 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
|
594 Idx subexp_to; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
595 char more; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
596 char unused; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
597 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
|
598 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
599 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
600 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
601 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
602 /* 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
|
603 re_string_t input; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
604 #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
|
605 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
|
606 #else |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
607 const re_dfa_t *dfa; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
608 #endif |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
609 /* EFLAGS of the argument of regexec. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
610 int eflags; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
611 /* 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
|
612 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
|
613 Idx last_node; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
614 /* 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
|
615 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
|
616 Idx state_log_top; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
617 /* 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
|
618 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
|
619 Idx abkref_ents; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
620 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
|
621 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
|
622 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
|
623 Idx asub_tops; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
624 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
|
625 } re_match_context_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
626 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
627 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
628 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
629 re_dfastate_t **sifted_states; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
630 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
|
631 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
|
632 Idx last_str_idx; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
633 re_node_set limits; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
634 } re_sift_context_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
635 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
636 struct re_fail_stack_ent_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
637 { |
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
|
638 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
|
639 Idx node; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
640 regmatch_t *regs; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
641 re_node_set eps_via_nodes; |
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 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
644 struct re_fail_stack_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
645 { |
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
|
646 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
|
647 Idx alloc; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
648 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
|
649 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
650 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
651 struct re_dfa_t |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
652 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
653 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
|
654 size_t nodes_alloc; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
655 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
|
656 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
|
657 Idx *org_indices; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
658 re_node_set *edests; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
659 re_node_set *eclosures; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
660 re_node_set *inveclosures; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
661 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
|
662 re_dfastate_t *init_state; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
663 re_dfastate_t *init_state_word; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
664 re_dfastate_t *init_state_nl; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
665 re_dfastate_t *init_state_begbuf; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
666 bin_tree_t *str_tree; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
667 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
|
668 re_bitset_ptr_t sb_char; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
669 int str_tree_storage_idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
670 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
671 /* 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
|
672 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
|
673 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
|
674 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
|
675 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
676 /* 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
|
677 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
|
678 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
|
679 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
680 unsigned int has_plural_match : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
681 /* 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
|
682 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
|
683 collating element. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
684 unsigned int has_mb_node : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
685 unsigned int is_utf8 : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
686 unsigned int map_notascii : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
687 unsigned int word_ops_used : 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
688 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
|
689 bitset_t word_char; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
690 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
|
691 Idx *subexp_map; |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
692 #ifdef DEBUG |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
693 char* re_str; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
694 #endif |
7066
3288bb324a28
* regex_internal.h (struct re_dfa_t) [!_LIBC]: Avoid invalid C89
Eric Blake <ebb9@byu.net>
parents:
6932
diff
changeset
|
695 #ifdef _LIBC |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
696 __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
|
697 #endif |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
698 }; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
699 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
700 #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
|
701 #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
|
702 (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
|
703 #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
|
704 #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
|
705 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
706 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
707 typedef enum |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
708 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
709 SB_CHAR, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
710 MB_CHAR, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
711 EQUIV_CLASS, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
712 COLL_SYM, |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
713 CHAR_CLASS |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
714 } bracket_elem_type; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
715 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
716 typedef struct |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
717 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
718 bracket_elem_type type; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
719 union |
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 unsigned char ch; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
722 unsigned char *name; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
723 wchar_t wch; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
724 } opr; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
725 } bracket_elem_t; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
726 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
727 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
728 /* 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
|
729 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
730 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
731 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
|
732 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
733 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
|
734 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
735 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
736 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
737 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
|
738 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
739 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
|
740 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
741 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
742 static inline bool |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
743 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
|
744 { |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
745 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
|
746 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
747 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
748 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
749 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
|
750 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
751 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
|
752 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
753 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
754 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
755 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
|
756 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
757 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
|
758 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
|
759 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
|
760 ((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
|
761 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
762 |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
763 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
764 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
|
765 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
766 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
|
767 } |
afb93b90dcb8
Change bitset word type from unsigned int to unsigned long int,
Paul Eggert <eggert@cs.ucla.edu>
parents:
6206
diff
changeset
|
768 |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
769 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
770 bitset_not (bitset_t set) |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
771 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
772 int bitset_i; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
773 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
|
774 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
|
775 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
|
776 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
|
777 ((((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
|
778 & ~set[BITSET_WORDS - 1]); |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
779 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
780 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
781 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
782 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
|
783 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
784 int bitset_i; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
785 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
|
786 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
|
787 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
788 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
789 static inline void |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
790 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
|
791 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
792 int bitset_i; |
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
793 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
|
794 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
|
795 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
796 |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
797 #ifdef RE_ENABLE_I18N |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
798 /* Inline functions for re_string. */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
799 static inline int |
6129
2fce0cb93f59
* config/srclist.text: Add glibc bug 1248.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6126
diff
changeset
|
800 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
|
801 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
|
802 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
803 int byte_idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
804 if (pstr->mb_cur_max == 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
805 return 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
806 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
|
807 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
|
808 break; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
809 return byte_idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
810 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
811 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
812 static inline wint_t |
6129
2fce0cb93f59
* config/srclist.text: Add glibc bug 1248.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6126
diff
changeset
|
813 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
|
814 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
|
815 { |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
816 if (pstr->mb_cur_max == 1) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
817 return (wint_t) pstr->mbs[idx]; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
818 return (wint_t) pstr->wcs[idx]; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
819 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
820 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
821 static int |
6129
2fce0cb93f59
* config/srclist.text: Add glibc bug 1248.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6126
diff
changeset
|
822 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
|
823 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
|
824 { |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
825 # ifdef _LIBC |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
826 const unsigned char *p, *extra; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
827 const int32_t *table, *indirect; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
828 int32_t tmp; |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
829 # include <locale/weight.h> |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
830 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
|
831 |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
832 if (nrules != 0) |
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 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
|
835 extra = (const unsigned char *) |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
836 _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
|
837 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
|
838 _NL_COLLATE_INDIRECTMB); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
839 p = pstr->mbs + idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
840 tmp = findidx (&p); |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
841 return p - pstr->mbs - idx; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
842 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
843 else |
6726
af9abbcedfbd
Merge regex changes from libc, removing some of our
Paul Eggert <eggert@cs.ucla.edu>
parents:
6539
diff
changeset
|
844 # endif /* _LIBC */ |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
845 return 1; |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
846 } |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
847 #endif /* RE_ENABLE_I18N */ |
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
848 |
12835 | 849 #ifndef __GNUC_PREREQ |
850 # if defined __GNUC__ && defined __GNUC_MINOR__ | |
851 # define __GNUC_PREREQ(maj, min) \ | |
852 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) | |
853 # else | |
854 # define __GNUC_PREREQ(maj, min) 0 | |
855 # endif | |
856 #endif | |
857 | |
12828
6c20461f3ecf
regex_internal.h: define __attribute_warn_unused_result__
Jim Meyering <meyering@redhat.com>
parents:
12567
diff
changeset
|
858 #if __GNUC_PREREQ (3,4) |
6c20461f3ecf
regex_internal.h: define __attribute_warn_unused_result__
Jim Meyering <meyering@redhat.com>
parents:
12567
diff
changeset
|
859 # undef __attribute_warn_unused_result__ |
6c20461f3ecf
regex_internal.h: define __attribute_warn_unused_result__
Jim Meyering <meyering@redhat.com>
parents:
12567
diff
changeset
|
860 # define __attribute_warn_unused_result__ \ |
6c20461f3ecf
regex_internal.h: define __attribute_warn_unused_result__
Jim Meyering <meyering@redhat.com>
parents:
12567
diff
changeset
|
861 __attribute__ ((__warn_unused_result__)) |
6c20461f3ecf
regex_internal.h: define __attribute_warn_unused_result__
Jim Meyering <meyering@redhat.com>
parents:
12567
diff
changeset
|
862 #else |
6c20461f3ecf
regex_internal.h: define __attribute_warn_unused_result__
Jim Meyering <meyering@redhat.com>
parents:
12567
diff
changeset
|
863 # define __attribute_warn_unused_result__ /* empty */ |
6c20461f3ecf
regex_internal.h: define __attribute_warn_unused_result__
Jim Meyering <meyering@redhat.com>
parents:
12567
diff
changeset
|
864 #endif |
6c20461f3ecf
regex_internal.h: define __attribute_warn_unused_result__
Jim Meyering <meyering@redhat.com>
parents:
12567
diff
changeset
|
865 |
5968
541fed6ae301
* modules/regex (Files): Add lib/regex_internal.c,
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
866 #endif /* _REGEX_INTERNAL_H */ |