regex.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. /* Definitions for data structures and routines for the regular
  2. expression library.
  3. Copyright (C) 1985,1989-93,1995-98,2000,2001,2002
  4. Free Software Foundation, Inc.
  5. This file is part of the GNU C Library.
  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. /* If this bit is set, then ignore case when matching.
  135. If not set, then case is significant. */
  136. #define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
  137. /* This global variable defines the particular regexp syntax to use (for
  138. some interfaces). When a regexp is compiled, the syntax used is
  139. stored in the pattern buffer, so changing this does not affect
  140. already-compiled regexps. */
  141. extern reg_syntax_t re_syntax_options;
  142. /* Define combinations of the above bits for the standard possibilities.
  143. (The [[[ comments delimit what gets put into the Texinfo file, so
  144. don't delete them!) */
  145. /* [[[begin syntaxes]]] */
  146. #define RE_SYNTAX_EMACS 0
  147. #define RE_SYNTAX_AWK \
  148. (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
  149. | RE_NO_BK_PARENS | RE_NO_BK_REFS \
  150. | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
  151. | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
  152. | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
  153. #define RE_SYNTAX_GNU_AWK \
  154. ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
  155. & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \
  156. | RE_CONTEXT_INVALID_OPS ))
  157. #define RE_SYNTAX_POSIX_AWK \
  158. (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
  159. | RE_INTERVALS | RE_NO_GNU_OPS)
  160. #define RE_SYNTAX_GREP \
  161. (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
  162. | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
  163. | RE_NEWLINE_ALT)
  164. #define RE_SYNTAX_EGREP \
  165. (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
  166. | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
  167. | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
  168. | RE_NO_BK_VBAR)
  169. #define RE_SYNTAX_POSIX_EGREP \
  170. (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
  171. | RE_INVALID_INTERVAL_ORD)
  172. /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
  173. #define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
  174. #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
  175. /* Syntax bits common to both basic and extended POSIX regex syntax. */
  176. #define _RE_SYNTAX_POSIX_COMMON \
  177. (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
  178. | RE_INTERVALS | RE_NO_EMPTY_RANGES)
  179. #define RE_SYNTAX_POSIX_BASIC \
  180. (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
  181. /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
  182. RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
  183. isn't minimal, since other operators, such as \`, aren't disabled. */
  184. #define RE_SYNTAX_POSIX_MINIMAL_BASIC \
  185. (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
  186. #define RE_SYNTAX_POSIX_EXTENDED \
  187. (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
  188. | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
  189. | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
  190. | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
  191. /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
  192. removed and RE_NO_BK_REFS is added. */
  193. #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
  194. (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
  195. | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
  196. | RE_NO_BK_PARENS | RE_NO_BK_REFS \
  197. | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
  198. /* [[[end syntaxes]]] */
  199. /* Maximum number of duplicates an interval can allow. Some systems
  200. (erroneously) define this in other header files, but we want our
  201. value, so remove any previous define. */
  202. #ifdef RE_DUP_MAX
  203. # undef RE_DUP_MAX
  204. #endif
  205. /* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
  206. #define RE_DUP_MAX (0x7fff)
  207. /* POSIX `cflags' bits (i.e., information for `regcomp'). */
  208. /* If this bit is set, then use extended regular expression syntax.
  209. If not set, then use basic regular expression syntax. */
  210. #define REG_EXTENDED 1
  211. /* If this bit is set, then ignore case when matching.
  212. If not set, then case is significant. */
  213. #define REG_ICASE (REG_EXTENDED << 1)
  214. /* If this bit is set, then anchors do not match at newline
  215. characters in the string.
  216. If not set, then anchors do match at newlines. */
  217. #define REG_NEWLINE (REG_ICASE << 1)
  218. /* If this bit is set, then report only success or fail in regexec.
  219. If not set, then returns differ between not matching and errors. */
  220. #define REG_NOSUB (REG_NEWLINE << 1)
  221. /* POSIX `eflags' bits (i.e., information for regexec). */
  222. /* If this bit is set, then the beginning-of-line operator doesn't match
  223. the beginning of the string (presumably because it's not the
  224. beginning of a line).
  225. If not set, then the beginning-of-line operator does match the
  226. beginning of the string. */
  227. #define REG_NOTBOL 1
  228. /* Like REG_NOTBOL, except for the end-of-line. */
  229. #define REG_NOTEOL (1 << 1)
  230. /* If any error codes are removed, changed, or added, update the
  231. `re_error_msg' table in regex.c. */
  232. typedef enum
  233. {
  234. #ifdef _XOPEN_SOURCE
  235. REG_ENOSYS = -1, /* This will never happen for this implementation. */
  236. #endif
  237. REG_NOERROR = 0, /* Success. */
  238. REG_NOMATCH, /* Didn't find a match (for regexec). */
  239. /* POSIX regcomp return error codes. (In the order listed in the
  240. standard.) */
  241. REG_BADPAT, /* Invalid pattern. */
  242. REG_ECOLLATE, /* Not implemented. */
  243. REG_ECTYPE, /* Invalid character class name. */
  244. REG_EESCAPE, /* Trailing backslash. */
  245. REG_ESUBREG, /* Invalid back reference. */
  246. REG_EBRACK, /* Unmatched left bracket. */
  247. REG_EPAREN, /* Parenthesis imbalance. */
  248. REG_EBRACE, /* Unmatched \{. */
  249. REG_BADBR, /* Invalid contents of \{\}. */
  250. REG_ERANGE, /* Invalid range end. */
  251. REG_ESPACE, /* Ran out of memory. */
  252. REG_BADRPT, /* No preceding re for repetition op. */
  253. /* Error codes we've added. */
  254. REG_EEND, /* Premature end. */
  255. REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
  256. REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
  257. } reg_errcode_t;
  258. /* This data structure represents a compiled pattern. Before calling
  259. the pattern compiler, the fields `buffer', `allocated', `fastmap',
  260. `translate', and `no_sub' can be set. After the pattern has been
  261. compiled, the `re_nsub' field is available. All other fields are
  262. private to the regex routines. */
  263. #ifndef RE_TRANSLATE_TYPE
  264. # define RE_TRANSLATE_TYPE char *
  265. #endif
  266. struct re_pattern_buffer
  267. {
  268. /* [[[begin pattern_buffer]]] */
  269. /* Space that holds the compiled pattern. It is declared as
  270. `unsigned char *' because its elements are
  271. sometimes used as array indexes. */
  272. unsigned char *buffer;
  273. /* Number of bytes to which `buffer' points. */
  274. unsigned long int allocated;
  275. /* Number of bytes actually used in `buffer'. */
  276. unsigned long int used;
  277. /* Syntax setting with which the pattern was compiled. */
  278. reg_syntax_t syntax;
  279. /* Pointer to a fastmap, if any, otherwise zero. re_search uses
  280. the fastmap, if there is one, to skip over impossible
  281. starting points for matches. */
  282. char *fastmap;
  283. /* Either a translate table to apply to all characters before
  284. comparing them, or zero for no translation. The translation
  285. is applied to a pattern when it is compiled and to a string
  286. when it is matched. */
  287. RE_TRANSLATE_TYPE translate;
  288. /* Number of subexpressions found by the compiler. */
  289. size_t re_nsub;
  290. /* Zero if this pattern cannot match the empty string, one else.
  291. Well, in truth it's used only in `re_search_2', to see
  292. whether or not we should use the fastmap, so we don't set
  293. this absolutely perfectly; see `re_compile_fastmap' (the
  294. `duplicate' case). */
  295. unsigned can_be_null : 1;
  296. /* If REGS_UNALLOCATED, allocate space in the `regs' structure
  297. for `max (RE_NREGS, re_nsub + 1)' groups.
  298. If REGS_REALLOCATE, reallocate space if necessary.
  299. If REGS_FIXED, use what's there. */
  300. #define REGS_UNALLOCATED 0
  301. #define REGS_REALLOCATE 1
  302. #define REGS_FIXED 2
  303. unsigned regs_allocated : 2;
  304. /* Set to zero when `regex_compile' compiles a pattern; set to one
  305. by `re_compile_fastmap' if it updates the fastmap. */
  306. unsigned fastmap_accurate : 1;
  307. /* If set, `re_match_2' does not return information about
  308. subexpressions. */
  309. unsigned no_sub : 1;
  310. /* If set, a beginning-of-line anchor doesn't match at the
  311. beginning of the string. */
  312. unsigned not_bol : 1;
  313. /* Similarly for an end-of-line anchor. */
  314. unsigned not_eol : 1;
  315. /* If true, an anchor at a newline matches. */
  316. unsigned newline_anchor : 1;
  317. /* [[[end pattern_buffer]]] */
  318. };
  319. typedef struct re_pattern_buffer regex_t;
  320. /* Type for byte offsets within the string. POSIX mandates this. */
  321. typedef int regoff_t;
  322. /* This is the structure we store register match data in. See
  323. regex.texinfo for a full description of what registers match. */
  324. struct re_registers
  325. {
  326. unsigned num_regs;
  327. regoff_t *start;
  328. regoff_t *end;
  329. };
  330. /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
  331. `re_match_2' returns information about at least this many registers
  332. the first time a `regs' structure is passed. */
  333. #ifndef RE_NREGS
  334. # define RE_NREGS 30
  335. #endif
  336. /* POSIX specification for registers. Aside from the different names than
  337. `re_registers', POSIX uses an array of structures, instead of a
  338. structure of arrays. */
  339. typedef struct
  340. {
  341. regoff_t rm_so; /* Byte offset from string's start to substring's start. */
  342. regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
  343. } regmatch_t;
  344. /* Declarations for routines. */
  345. /* To avoid duplicating every routine declaration -- once with a
  346. prototype (if we are ANSI), and once without (if we aren't) -- we
  347. use the following macro to declare argument types. This
  348. unfortunately clutters up the declarations a bit, but I think it's
  349. worth it. */
  350. #if __STDC__
  351. # define _RE_ARGS(args) args
  352. #else /* not __STDC__ */
  353. # define _RE_ARGS(args) ()
  354. #endif /* not __STDC__ */
  355. /* Sets the current default syntax to SYNTAX, and return the old syntax.
  356. You can also simply assign to the `re_syntax_options' variable. */
  357. extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
  358. /* Compile the regular expression PATTERN, with length LENGTH
  359. and syntax given by the global `re_syntax_options', into the buffer
  360. BUFFER. Return NULL if successful, and an error string if not. */
  361. extern const char *re_compile_pattern
  362. _RE_ARGS ((const char *pattern, size_t length,
  363. struct re_pattern_buffer *buffer));
  364. /* Compile a fastmap for the compiled pattern in BUFFER; used to
  365. accelerate searches. Return 0 if successful and -2 if was an
  366. internal error. */
  367. extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
  368. /* Search in the string STRING (with length LENGTH) for the pattern
  369. compiled into BUFFER. Start searching at position START, for RANGE
  370. characters. Return the starting position of the match, -1 for no
  371. match, or -2 for an internal error. Also return register
  372. information in REGS (if REGS and BUFFER->no_sub are nonzero). */
  373. extern int re_search
  374. _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
  375. int length, int start, int range, struct re_registers *regs));
  376. /* Like `re_search', but search in the concatenation of STRING1 and
  377. STRING2. Also, stop searching at index START + STOP. */
  378. extern int re_search_2
  379. _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
  380. int length1, const char *string2, int length2,
  381. int start, int range, struct re_registers *regs, int stop));
  382. /* Like `re_search', but return how many characters in STRING the regexp
  383. in BUFFER matched, starting at position START. */
  384. extern int re_match
  385. _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
  386. int length, int start, struct re_registers *regs));
  387. /* Relates to `re_match' as `re_search_2' relates to `re_search'. */
  388. extern int re_match_2
  389. _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
  390. int length1, const char *string2, int length2,
  391. int start, struct re_registers *regs, int stop));
  392. /* Set REGS to hold NUM_REGS registers, storing them in STARTS and
  393. ENDS. Subsequent matches using BUFFER and REGS will use this memory
  394. for recording register information. STARTS and ENDS must be
  395. allocated with malloc, and must each be at least `NUM_REGS * sizeof
  396. (regoff_t)' bytes long.
  397. If NUM_REGS == 0, then subsequent matches should allocate their own
  398. register data.
  399. Unless this function is called, the first search or match using
  400. PATTERN_BUFFER will allocate its own register data, without
  401. freeing the old data. */
  402. extern void re_set_registers
  403. _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
  404. unsigned num_regs, regoff_t *starts, regoff_t *ends));
  405. #if defined _REGEX_RE_COMP || defined _LIBC
  406. # ifndef _CRAY
  407. /* 4.2 bsd compatibility. */
  408. extern char *re_comp _RE_ARGS ((const char *));
  409. extern int re_exec _RE_ARGS ((const char *));
  410. # endif
  411. #endif
  412. /* GCC 2.95 and later have "__restrict"; C99 compilers have
  413. "restrict", and "configure" may have defined "restrict". */
  414. #ifndef __restrict
  415. # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
  416. # if defined restrict || 199901L <= __STDC_VERSION__
  417. # define __restrict restrict
  418. # else
  419. # define __restrict
  420. # endif
  421. # endif
  422. #endif
  423. /* gcc 3.1 and up support the [restrict] syntax. */
  424. #ifndef __restrict_arr
  425. # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
  426. # define __restrict_arr __restrict
  427. # else
  428. # define __restrict_arr
  429. # endif
  430. #endif
  431. /* POSIX compatibility. */
  432. extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
  433. const char *__restrict __pattern,
  434. int __cflags));
  435. extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
  436. const char *__restrict __string, size_t __nmatch,
  437. regmatch_t __pmatch[__restrict_arr],
  438. int __eflags));
  439. extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
  440. char *__errbuf, size_t __errbuf_size));
  441. extern void regfree _RE_ARGS ((regex_t *__preg));
  442. #ifdef __cplusplus
  443. }
  444. #endif /* C++ */
  445. #endif /* regex.h */
  446. /*
  447. Local variables:
  448. make-backup-files: t
  449. version-control: t
  450. trim-versions-without-asking: nil
  451. End:
  452. */