PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/regex.h

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