Mercurial > cpython-lru_cache-weakref
annotate Modules/regexpr.h @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | 4866a0fc2bbd |
| children | 09e6b4e34523 |
| rev | line source |
|---|---|
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
1 #ifndef Py_REGEXPR_H |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
2 #define Py_REGEXPR_H |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
3 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
4 extern "C" { |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
5 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
6 |
| 616 | 7 /* |
| 8 | |
| 9 regexpr.h | |
| 10 | |
| 11 Author: Tatu Ylonen <ylo@ngs.fi> | |
| 12 | |
| 13 Copyright (c) 1991 Tatu Ylonen, Espoo, Finland | |
| 14 | |
| 15 Permission to use, copy, modify, distribute, and sell this software | |
| 16 and its documentation for any purpose is hereby granted without fee, | |
| 17 provided that the above copyright notice appear in all copies. This | |
| 18 software is provided "as is" without express or implied warranty. | |
| 19 | |
| 20 Created: Thu Sep 26 17:15:36 1991 ylo | |
| 21 Last modified: Mon Nov 4 15:49:46 1991 ylo | |
| 22 | |
| 23 */ | |
| 24 | |
| 25 #ifndef REGEXPR_H | |
| 26 #define REGEXPR_H | |
| 27 | |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
640
diff
changeset
|
28 #define RE_NREGS 100 /* number of registers available */ |
| 616 | 29 |
| 30 typedef struct re_pattern_buffer | |
| 31 { | |
| 32 char *buffer; /* compiled pattern */ | |
| 33 int allocated; /* allocated size of compiled pattern */ | |
| 34 int used; /* actual length of compiled pattern */ | |
| 35 char *fastmap; /* fastmap[ch] is true if ch can start pattern */ | |
| 36 char *translate; /* translation to apply during compilation/matching */ | |
| 37 char fastmap_accurate; /* true if fastmap is valid */ | |
| 38 char can_be_null; /* true if can match empty string */ | |
| 39 char uses_registers; /* registers are used and need to be initialized */ | |
| 40 char anchor; /* anchor: 0=none 1=begline 2=begbuf */ | |
| 41 } *regexp_t; | |
| 42 | |
| 43 typedef struct re_registers | |
| 44 { | |
| 45 int start[RE_NREGS]; /* start offset of region */ | |
| 46 int end[RE_NREGS]; /* end offset of region */ | |
| 47 } *regexp_registers_t; | |
| 48 | |
| 49 /* bit definitions for syntax */ | |
| 50 #define RE_NO_BK_PARENS 1 /* no quoting for parentheses */ | |
| 51 #define RE_NO_BK_VBAR 2 /* no quoting for vertical bar */ | |
| 52 #define RE_BK_PLUS_QM 4 /* quoting needed for + and ? */ | |
| 53 #define RE_TIGHT_VBAR 8 /* | binds tighter than ^ and $ */ | |
| 54 #define RE_NEWLINE_OR 16 /* treat newline as or */ | |
| 55 #define RE_CONTEXT_INDEP_OPS 32 /* ^$?*+ are special in all contexts */ | |
| 56 #define RE_ANSI_HEX 64 /* ansi sequences (\n etc) and \xhh */ | |
| 57 #define RE_NO_GNU_EXTENSIONS 128 /* no gnu extensions */ | |
| 58 | |
| 59 /* definitions for some common regexp styles */ | |
| 60 #define RE_SYNTAX_AWK (RE_NO_BK_PARENS|RE_NO_BK_VBAR|RE_CONTEXT_INDEP_OPS) | |
| 61 #define RE_SYNTAX_EGREP (RE_SYNTAX_AWK|RE_NEWLINE_OR) | |
| 62 #define RE_SYNTAX_GREP (RE_BK_PLUS_QM|RE_NEWLINE_OR) | |
| 63 #define RE_SYNTAX_EMACS 0 | |
| 64 | |
|
3612
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
65 /* Rename all exported symbols to avoid conflicts with similarly named |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
66 symbols in some systems' standard C libraries... */ |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
67 |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
68 #define re_syntax _Py_re_syntax |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
69 #define re_set_syntax _Py_re_set_syntax |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
70 #define re_compile_pattern _Py_re_compile_pattern |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
71 #define re_match _Py_re_match |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
72 #define re_match_2 _Py_re_match_2 |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
73 #define re_search _Py_re_search |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
74 #define re_search_2 _Py_re_search_2 |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
75 #define re_compile_fastmap _Py_re_compile_fastmap |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
76 #define re_comp _Py_re_comp |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
77 #define re_exec _Py_re_exec |
|
4866a0fc2bbd
rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
78 |
|
640
0b38000fc823
Change prototypes decision.
Guido van Rossum <guido@python.org>
parents:
616
diff
changeset
|
79 #ifdef HAVE_PROTOTYPES |
| 616 | 80 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
81 extern int re_syntax; |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
82 /* This is the actual syntax mask. It was added so that Python |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
83 could do syntax-dependent munging of patterns before compilation. */ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
84 |
| 616 | 85 int re_set_syntax(int syntax); |
| 86 /* This sets the syntax to use and returns the previous syntax. The | |
| 87 syntax is specified by a bit mask of the above defined bits. */ | |
| 88 | |
| 89 char *re_compile_pattern(char *regex, int regex_size, regexp_t compiled); | |
| 90 /* This compiles the regexp (given in regex and length in regex_size). | |
| 91 This returns NULL if the regexp compiled successfully, and an error | |
| 92 message if an error was encountered. The buffer field must be | |
| 93 initialized to a memory area allocated by malloc (or to NULL) before | |
| 94 use, and the allocated field must be set to its length (or 0 if buffer is | |
| 95 NULL). Also, the translate field must be set to point to a valid | |
| 96 translation table, or NULL if it is not used. */ | |
| 97 | |
| 98 int re_match(regexp_t compiled, char *string, int size, int pos, | |
| 99 regexp_registers_t regs); | |
| 100 /* This tries to match the regexp against the string. This returns the | |
| 101 length of the matched portion, or -1 if the pattern could not be | |
| 102 matched and -2 if an error (such as failure stack overflow) is | |
| 103 encountered. */ | |
| 104 | |
| 105 int re_match_2(regexp_t compiled, char *string1, int size1, | |
| 106 char *string2, int size2, int pos, regexp_registers_t regs, | |
| 107 int mstop); | |
| 108 /* This tries to match the regexp to the concatenation of string1 and | |
| 109 string2. This returns the length of the matched portion, or -1 if the | |
| 110 pattern could not be matched and -2 if an error (such as failure stack | |
| 111 overflow) is encountered. */ | |
| 112 | |
| 113 int re_search(regexp_t compiled, char *string, int size, int startpos, | |
| 114 int range, regexp_registers_t regs); | |
| 115 /* This rearches for a substring matching the regexp. This returns the first | |
| 116 index at which a match is found. range specifies at how many positions to | |
| 117 try matching; positive values indicate searching forwards, and negative | |
| 118 values indicate searching backwards. mstop specifies the offset beyond | |
| 119 which a match must not go. This returns -1 if no match is found, and | |
| 120 -2 if an error (such as failure stack overflow) is encountered. */ | |
| 121 | |
| 122 int re_search_2(regexp_t compiled, char *string1, int size1, | |
| 123 char *string2, int size2, int startpos, int range, | |
| 124 regexp_registers_t regs, int mstop); | |
| 125 /* This is like re_search, but search from the concatenation of string1 and | |
| 126 string2. */ | |
| 127 | |
| 128 void re_compile_fastmap(regexp_t compiled); | |
| 129 /* This computes the fastmap for the regexp. For this to have any effect, | |
| 130 the calling program must have initialized the fastmap field to point | |
| 131 to an array of 256 characters. */ | |
| 132 | |
| 133 char *re_comp(char *s); | |
| 134 /* BSD 4.2 regex library routine re_comp. This compiles the regexp into | |
| 135 an internal buffer. This returns NULL if the regexp was compiled | |
| 136 successfully, and an error message if there was an error. */ | |
| 137 | |
| 138 int re_exec(char *s); | |
| 139 /* BSD 4.2 regexp library routine re_exec. This returns true if the string | |
| 140 matches the regular expression (that is, a matching part is found | |
| 141 anywhere in the string). */ | |
| 142 | |
|
640
0b38000fc823
Change prototypes decision.
Guido van Rossum <guido@python.org>
parents:
616
diff
changeset
|
143 #else /* HAVE_PROTOTYPES */ |
| 616 | 144 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1329
diff
changeset
|
145 extern int re_syntax; |
| 616 | 146 int re_set_syntax(); |
| 147 char *re_compile_pattern(); | |
| 148 int re_match(); | |
| 149 int re_match_2(); | |
| 150 int re_search(); | |
| 151 int re_search_2(); | |
| 152 void re_compile_fastmap(); | |
| 153 char *re_comp(); | |
| 154 int re_exec(); | |
| 155 | |
|
640
0b38000fc823
Change prototypes decision.
Guido van Rossum <guido@python.org>
parents:
616
diff
changeset
|
156 #endif /* HAVE_PROTOTYPES */ |
| 616 | 157 |
| 158 #endif /* REGEXPR_H */ | |
| 159 | |
| 160 | |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
161 |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
162 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
163 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
164 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1273
diff
changeset
|
165 #endif /* !Py_REGEXPR_H */ |
