regex.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /* Definitions for data structures and routines for the regular
  2. expression library, version 0.12.
  3. Copyright (C) 1985,1989-1993,1995-1998, 2000 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library. Its master source is NOT part of
  5. the C library, however. The master source lives in /gd/gnu/lib.
  6. The GNU C Library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public
  8. License as published by the Free Software Foundation; either
  9. version 2.1 of the License, or (at your option) any later version.
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with the GNU C Library; if not, write to the Free
  16. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  17. 02111-1307 USA. */
  18. #ifndef _REGEX_H
  19. #define _REGEX_H 1
  20. /* Allow the use in C++ code. */
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* POSIX says that <sys/types.h> must be included (by the caller) before
  25. <regex.h>. */
  26. #if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
  27. /* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
  28. should be there. */
  29. # include <stddef.h>
  30. #endif
  31. /* The following two types have to be signed and unsigned integer type
  32. wide enough to hold a value of a pointer. For most ANSI compilers
  33. ptrdiff_t and size_t should be likely OK. Still size of these two
  34. types is 2 for Microsoft C. Ugh... */
  35. typedef long int s_reg_t;
  36. typedef unsigned long int active_reg_t;
  37. /* The following bits are used to determine the regexp syntax we
  38. recognize. The set/not-set meanings are chosen so that Emacs syntax
  39. remains the value 0. The bits are given in alphabetical order, and
  40. the definitions shifted by one from the previous bit; thus, when we
  41. add or remove a bit, only one other definition need change. */
  42. typedef unsigned long int reg_syntax_t;
  43. /* If this bit is not set, then \ inside a bracket expression is literal.
  44. If set, then such a \ quotes the following character. */
  45. #define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
  46. /* If this bit is not set, then + and ? are operators, and \+ and \? are
  47. literals.
  48. If set, then \+ and \? are operators and + and ? are literals. */
  49. #define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
  50. /* If this bit is set, then character classes are supported. They are:
  51. [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
  52. [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
  53. If not set, then character classes are not supported. */
  54. #define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
  55. /* If this bit is set, then ^ and $ are always anchors (outside bracket
  56. expressions, of course).
  57. If this bit is not set, then it depends:
  58. ^ is an anchor if it is at the beginning of a regular
  59. expression or after an open-group or an alternation operator;
  60. $ is an anchor if it is at the end of a regular expression, or
  61. before a close-group or an alternation operator.
  62. This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
  63. POSIX draft 11.2 says that * etc. in leading positions is undefined.
  64. We already implemented a previous draft which made those constructs
  65. invalid, though, so we haven't changed the code back. */
  66. #define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
  67. /* If this bit is set, then special characters are always special
  68. regardless of where they are in the pattern.
  69. If this bit is not set, then special characters are special only in
  70. some contexts; otherwise they are ordinary. Specifically,
  71. * + ? and intervals are only special when not after the beginning,
  72. open-group, or alternation operator. */
  73. #define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
  74. /* If this bit is set, then *, +, ?, and { cannot be first in an re or
  75. immediately after an alternation or begin-group operator. */
  76. #define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
  77. /* If this bit is set, then . matches newline.
  78. If not set, then it doesn't. */
  79. #define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
  80. /* If this bit is set, then . doesn't match NUL.
  81. If not set, then it does. */
  82. #define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
  83. /* If this bit is set, nonmatching lists [^...] do not match newline.
  84. If not set, they do. */
  85. #define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
  86. /* If this bit is set, either \{...\} or {...} defines an
  87. interval, depending on RE_NO_BK_BRACES.
  88. If not set, \{, \}, {, and } are literals. */
  89. #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
  90. /* If this bit is set, +, ? and | aren't recognized as operators.
  91. If not set, they are. */
  92. #define RE_LIMITED_OPS (RE_INTERVALS << 1)
  93. /* If this bit is set, newline is an alternation operator.
  94. If not set, newline is literal. */
  95. #define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
  96. /* If this bit is set, then `{...}' defines an interval, and \{ and \}
  97. are literals.
  98. If not set, then `\{...\}' defines an interval. */
  99. #define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
  100. /* If this bit is set, (...) defines a group, and \( and \) are literals.
  101. If not set, \(...\) defines a group, and ( and ) are literals. */
  102. #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
  103. /* If this bit is set, then \<digit> matches <digit>.
  104. If not set, then \<digit> is a back-reference. */
  105. #define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
  106. /* If this bit is set, then | is an alternation operator, and \| is literal.
  107. If not set, then \| is an alternation operator, and | is literal. */
  108. #define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
  109. /* If this bit is set, then an ending range point collating higher
  110. than the starting range point, as in [z-a], is invalid.
  111. If not set, then when ending range point collates higher than the
  112. starting range point, the range is ignored. */
  113. #define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
  114. /* If this bit is set, then an unmatched ) is ordinary.
  115. If not set, then an unmatched ) is invalid. */
  116. #define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
  117. /* If this bit is set, succeed as soon as we match the whole pattern,
  118. without further backtracking. */
  119. #define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
  120. /* If this bit is set, do not process the GNU regex operators.
  121. If not set, then the GNU regex operators are recognized. */
  122. #define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
  123. /* If this bit is set, turn on internal regex debugging.
  124. If not set, and debugging was on, turn it off.
  125. This only works if regex.c is compiled -DDEBUG.
  126. We define this bit always, so that all that's needed to turn on
  127. debugging is to recompile regex.c; the calling code can always have
  128. this bit set, and it won't affect anything in the normal case. */
  129. #define RE_DEBUG (RE_NO_GNU_OPS << 1)
  130. /* If this bit is set, a syntactically invalid interval is treated as
  131. a string of ordinary characters. For example, the ERE 'a{1' is
  132. treated as 'a\{1'. */
  133. #define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
  134. /* This global variable defines the particular regexp syntax to use (for
  135. some interfaces). When a regexp is compiled, the syntax used is
  136. stored in the pattern buffer, so changing this does not affect
  137. already-compiled regexps. */
  138. extern reg_syntax_t re_syntax_options;
  139. /* Define combinations of the above bits for the standard possibilities.
  140. (The [[[ comments delimit what gets put into the Texinfo file, so
  141. don't delete them!) */
  142. /* [[[begin syntaxes]]] */
  143. #define RE_SYNTAX_EMACS 0
  144. #define RE_SYNTAX_AWK \
  145. (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
  146. | RE_NO_BK_PARENS | RE_NO_BK_REFS \
  147. | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
  148. | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
  149. | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
  150. #define RE_SYNTAX_GNU_AWK \
  151. ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
  152. & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
  153. #define RE_SYNTAX_POSIX_AWK \
  154. (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
  155. | RE_INTERVALS | RE_NO_GNU_OPS)
  156. #define RE_SYNTAX_GREP \
  157. (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
  158. | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
  159. | RE_NEWLINE_ALT)
  160. #define RE_SYNTAX_EGREP \
  161. (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
  162. | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
  163. | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
  164. | RE_NO_BK_VBAR)
  165. #define RE_SYNTAX_POSIX_EGREP \
  166. (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
  167. | RE_INVALID_INTERVAL_ORD)
  168. /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
  169. #define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
  170. #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
  171. /* Syntax bits common to both basic and extended POSIX regex syntax. */
  172. #define _RE_SYNTAX_POSIX_COMMON \
  173. (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
  174. | RE_INTERVALS | RE_NO_EMPTY_RANGES)
  175. #define RE_SYNTAX_POSIX_BASIC \
  176. (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
  177. /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
  178. RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
  179. isn't minimal, since other operators, such as \`, aren't disabled. */
  180. #define RE_SYNTAX_POSIX_MINIMAL_BASIC \
  181. (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
  182. #define RE_SYNTAX_POSIX_EXTENDED \
  183. (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
  184. | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
  185. | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  186. | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
  187. /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
  188. removed and RE_NO_BK_REFS is added. */
  189. #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
  190. (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
  191. | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
  192. | RE_NO_BK_PARENS | RE_NO_BK_REFS \
  193. | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
  194. /* [[[end syntaxes]]] */
  195. /* Maximum number of duplicates an interval can allow. Some systems
  196. (erroneously) define this in other header files, but we want our
  197. value, so remove any previous define. */
  198. #ifdef RE_DUP_MAX
  199. # undef RE_DUP_MAX
  200. #endif
  201. /* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
  202. #define RE_DUP_MAX (0x7fff)
  203. /* POSIX `cflags' bits (i.e., information for `regcomp'). */
  204. /* If this bit is set, then use extended regular expression syntax.
  205. If not set, then use basic regular expression syntax. */
  206. #define REG_EXTENDED 1
  207. /* If this bit is set, then ignore case when matching.
  208. If not set, then case is significant. */
  209. #define REG_ICASE (REG_EXTENDED << 1)
  210. /* If this bit is set, then anchors do not match at newline
  211. characters in the string.
  212. If not set, then anchors do match at newlines. */
  213. #define REG_NEWLINE (REG_ICASE << 1)
  214. /* If this bit is set, then report only success or fail in regexec.
  215. If not set, then returns differ between not matching and errors. */
  216. #define REG_NOSUB (REG_NEWLINE << 1)
  217. /* POSIX `eflags' bits (i.e., information for regexec). */
  218. /* If this bit is set, then the beginning-of-line operator doesn't match
  219. the beginning of the string (presumably because it's not the
  220. beginning of a line).
  221. If not set, then the beginning-of-line operator does match the
  222. beginning of the string. */
  223. #define REG_NOTBOL 1
  224. /* Like REG_NOTBOL, except for the end-of-line. */
  225. #define REG_NOTEOL (1 << 1)
  226. /* If any error codes are removed, changed, or added, update the
  227. `re_error_msg' table in regex.c. */
  228. typedef enum
  229. {
  230. #ifdef _XOPEN_SOURCE
  231. REG_ENOSYS = -1, /* This will never happen for this implementation. */
  232. #endif
  233. REG_NOERROR = 0, /* Success. */
  234. REG_NOMATCH, /* Didn't find a match (for regexec). */
  235. /* POSIX regcomp return error codes. (In the order listed in the
  236. standard.) */
  237. REG_BADPAT, /* Invalid pattern. */
  238. REG_ECOLLATE, /* Not implemented. */
  239. REG_ECTYPE, /* Invalid character class name. */
  240. REG_EESCAPE, /* Trailing backslash. */
  241. REG_ESUBREG, /* Invalid back reference. */
  242. REG_EBRACK, /* Unmatched left bracket. */
  243. REG_EPAREN, /* Parenthesis imbalance. */
  244. REG_EBRACE, /* Unmatched \{. */
  245. REG_BADBR, /* Invalid contents of \{\}. */
  246. REG_ERANGE, /* Invalid range end. */
  247. REG_ESPACE, /* Ran out of memory. */
  248. REG_BADRPT, /* No preceding re for repetition op. */
  249. /* Error codes we've added. */
  250. REG_EEND, /* Premature end. */
  251. REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
  252. REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
  253. } reg_errcode_t;
  254. /* This data structure represents a compiled pattern. Before calling
  255. the pattern compiler, the fields `buffer', `allocated', `fastmap',
  256. `translate', and `no_sub' can be set. After the pattern has been
  257. compiled, the `re_nsub' field is available. All other fields are
  258. private to the regex routines. */
  259. #ifndef RE_TRANSLATE_TYPE
  260. # define RE_TRANSLATE_TYPE char *
  261. #endif
  262. struct re_pattern_buffer
  263. {
  264. /* [[[begin pattern_buffer]]] */
  265. /* Space that holds the compiled pattern. It is declared as
  266. `unsigned char *' because its elements are
  267. sometimes used as array indexes. */
  268. unsigned char *buffer;
  269. /* Number of bytes to which `buffer' points. */
  270. unsigned long int allocated;
  271. /* Number of bytes actually used in `buffer'. */
  272. unsigned long int used;
  273. /* Syntax setting with which the pattern was compiled. */
  274. reg_syntax_t syntax;
  275. /* Pointer to a fastmap, if any, otherwise zero. re_search uses
  276. the fastmap, if there is one, to skip over impossible
  277. starting points for matches. */
  278. char *fastmap;
  279. /* Either a translate table to apply to all characters before
  280. comparing them, or zero for no translation. The translation
  281. is applied to a pattern when it is compiled and to a string
  282. when it is matched. */
  283. RE_TRANSLATE_TYPE translate;
  284. /* Number of subexpressions found by the compiler. */
  285. size_t re_nsub;
  286. /* Zero if this pattern cannot match the empty string, one else.
  287. Well, in truth it's used only in `re_search_2', to see
  288. whether or not we should use the fastmap, so we don't set
  289. this absolutely perfectly; see `re_compile_fastmap' (the
  290. `duplicate' case). */
  291. unsigned can_be_null : 1;
  292. /* If REGS_UNALLOCATED, allocate space in the `regs' structure
  293. for `max (RE_NREGS, re_nsub + 1)' groups.
  294. If REGS_REALLOCATE, reallocate space if necessary.
  295. If REGS_FIXED, use what's there. */
  296. #define REGS_UNALLOCATED 0
  297. #define REGS_REALLOCATE 1
  298. #define REGS_FIXED 2
  299. unsigned regs_allocated : 2;
  300. /* Set to zero when `regex_compile' compiles a pattern; set to one
  301. by `re_compile_fastmap' if it updates the fastmap. */
  302. unsigned fastmap_accurate : 1;
  303. /* If set, `re_match_2' does not return information about
  304. subexpressions. */
  305. unsigned no_sub : 1;
  306. /* If set, a beginning-of-line anchor doesn't match at the
  307. beginning of the string. */
  308. unsigned not_bol : 1;
  309. /* Similarly for an end-of-line anchor. */
  310. unsigned not_eol : 1;
  311. /* If true, an anchor at a newline matches. */
  312. unsigned newline_anchor : 1;
  313. /* [[[end pattern_buffer]]] */
  314. };
  315. typedef struct re_pattern_buffer regex_t;
  316. /* Type for byte offsets within the string. POSIX mandates this. */
  317. typedef int regoff_t;
  318. /* This is the structure we store register match data in. See
  319. regex.texinfo for a full description of what registers match. */
  320. struct re_registers
  321. {
  322. unsigned num_regs;
  323. regoff_t *start;
  324. regoff_t *end;
  325. };
  326. /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
  327. `re_match_2' returns information about at least this many registers
  328. the first time a `regs' structure is passed. */
  329. #ifndef RE_NREGS
  330. # define RE_NREGS 30
  331. #endif
  332. /* POSIX specification for registers. Aside from the different names than
  333. `re_registers', POSIX uses an array of structures, instead of a
  334. structure of arrays. */
  335. typedef struct
  336. {
  337. regoff_t rm_so; /* Byte offset from string's start to substring's start. */
  338. regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
  339. } regmatch_t;
  340. /* Declarations for routines. */
  341. /* To avoid duplicating every routine declaration -- once with a
  342. prototype (if we are ANSI), and once without (if we aren't) -- we
  343. use the following macro to declare argument types. This
  344. unfortunately clutters up the declarations a bit, but I think it's
  345. worth it. */
  346. #if __STDC__
  347. # define _RE_ARGS(args) args
  348. #else /* not __STDC__ */
  349. # define _RE_ARGS(args) ()
  350. #endif /* not __STDC__ */
  351. /* Sets the current default syntax to SYNTAX, and return the old syntax.
  352. You can also simply assign to the `re_syntax_options' variable. */
  353. extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
  354. /* Compile the regular expression PATTERN, with length LENGTH
  355. and syntax given by the global `re_syntax_options', into the buffer
  356. BUFFER. Return NULL if successful, and an error string if not. */
  357. extern const char *re_compile_pattern
  358. _RE_ARGS ((const char *pattern, size_t length,
  359. struct re_pattern_buffer *buffer));
  360. /* Compile a fastmap for the compiled pattern in BUFFER; used to
  361. accelerate searches. Return 0 if successful and -2 if was an
  362. internal error. */
  363. extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
  364. /* Search in the string STRING (with length LENGTH) for the pattern
  365. compiled into BUFFER. Start searching at position START, for RANGE
  366. characters. Return the starting position of the match, -1 for no
  367. match, or -2 for an internal error. Also return register
  368. information in REGS (if REGS and BUFFER->no_sub are nonzero). */
  369. extern int re_search
  370. _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
  371. int length, int start, int range, struct re_registers *regs));
  372. /* Like `re_search', but search in the concatenation of STRING1 and
  373. STRING2. Also, stop searching at index START + STOP. */
  374. extern int re_search_2
  375. _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
  376. int length1, const char *string2, int length2,
  377. int start, int range, struct re_registers *regs, int stop));
  378. /* Like `re_search', but return how many characters in STRING the regexp
  379. in BUFFER matched, starting at position START. */
  380. extern int re_match
  381. _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
  382. int length, int start, struct re_registers *regs));
  383. /* Relates to `re_match' as `re_search_2' relates to `re_search'. */
  384. extern int re_match_2
  385. _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
  386. int length1, const char *string2, int length2,
  387. int start, struct re_registers *regs, int stop));
  388. /* Set REGS to hold NUM_REGS registers, storing them in STARTS and
  389. ENDS. Subsequent matches using BUFFER and REGS will use this memory
  390. for recording register information. STARTS and ENDS must be
  391. allocated with malloc, and must each be at least `NUM_REGS * sizeof
  392. (regoff_t)' bytes long.
  393. If NUM_REGS == 0, then subsequent matches should allocate their own
  394. register data.
  395. Unless this function is called, the first search or match using
  396. PATTERN_BUFFER will allocate its own register data, without
  397. freeing the old data. */
  398. extern void re_set_registers
  399. _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
  400. unsigned num_regs, regoff_t *starts, regoff_t *ends));
  401. #if defined _REGEX_RE_COMP || defined _LIBC
  402. # ifndef _CRAY
  403. /* 4.2 bsd compatibility. */
  404. extern char *re_comp _RE_ARGS ((const char *));
  405. extern int re_exec _RE_ARGS ((const char *));
  406. # endif
  407. #endif
  408. /* GCC 2.95 and later have "__restrict"; C99 compilers have
  409. "restrict", and "configure" may have defined "restrict". */
  410. #ifndef __restrict
  411. # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
  412. # if defined restrict || 199901L <= __STDC_VERSION__
  413. # define __restrict restrict
  414. # else
  415. # define __restrict
  416. # endif
  417. # endif
  418. #endif
  419. /* For now unconditionally define __restrict_arr to expand to nothing.
  420. Ideally we would have a test for the compiler which allows defining
  421. it to restrict. */
  422. #define __restrict_arr
  423. /* POSIX compatibility. */
  424. extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
  425. const char *__restrict __pattern,
  426. int __cflags));
  427. extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
  428. const char *__restrict __string, size_t __nmatch,
  429. regmatch_t __pmatch[__restrict_arr],
  430. int __eflags));
  431. extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
  432. char *__errbuf, size_t __errbuf_size));
  433. extern void regfree _RE_ARGS ((regex_t *__preg));
  434. #ifdef __cplusplus
  435. }
  436. #endif /* C++ */
  437. #endif /* regex.h */
  438. /*
  439. Local variables:
  440. make-backup-files: t
  441. version-control: t
  442. trim-versions-without-asking: nil
  443. End:
  444. */