home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / futils / futils~1 / src / text11s.zoo / text1.1 / lib / regex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-02  |  21.0 KB  |  591 lines

  1. /* Definitions for data structures callers pass the regex library.
  2.    Version 0.1.
  3.    Copyright (C) 1985, 89, 90, 91 Free Software Foundation, Inc.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program 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
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19.  
  20. #ifndef __REGEXP_LIBRARY
  21. #define __REGEXP_LIBRARY
  22.  
  23.  
  24.  
  25. /* This defines the particular regexp syntax to use.  */
  26. extern int obscure_syntax;
  27.  
  28.  
  29. /* The following bits are used in the obscure_syntax variable to choose among
  30.    alternative regexp syntaxes.  */
  31.  
  32. /* If this bit is set, (...) defines a group, and \( and \) are literals.
  33.    If not set, \(...\) defines a group, and ( and ) are literals.  */
  34. #define RE_NO_BK_PARENS    1
  35.  
  36. /* If this bit is set, then | is an alternation operator, and \| is literal. 
  37.    If not set, then \| is an alternation operator, and | is literal.  */
  38. #define RE_NO_BK_VBAR (1 << 1)
  39.  
  40. /* If this bit is not set, then + and ? are operators, and \+ and \? are
  41.      literals. 
  42.    If set, then \+ and \? are operators and + and ? are literals.  */
  43. #define RE_BK_PLUS_QM (1 << 2)
  44.  
  45. /* If this bit is set, then | binds tighter than ^ or $.
  46.    If not set, the contrary.  */
  47. #define RE_TIGHT_ALT (1 << 3)
  48.  
  49. /* If this bit is set, newline is an alternation operator.
  50.    If not set, then newline is literal.  */
  51. #define RE_NEWLINE_ALT (1 << 4)
  52.  
  53. /* If this bit is set, then special characters are always special
  54.      regardless of where they are in the pattern.
  55.    If this bit is not set, then special characters are special only in
  56.      some contexts; otherwise they are ordinary.  Specifically, 
  57.      
  58.     *  + ?  and intervals are only special when not after the beginning,
  59.         open-group, or alternation operator.  */
  60. #define RE_CONTEXT_INDEP_OPS (1 << 5)
  61.  
  62. /* If this bit is not set, then \ inside a bracket expression is literal.
  63.    If set, then such a \ quotes the following character.  */
  64. #define RE_AWK_CLASS_HACK (1 << 6)
  65.  
  66. /* If this bit is set, then either \{...\} or {...} defines an
  67.      interval, depending on RE_NO_BK_BRACES. 
  68.    If not set, then \{, \}, {, and } are literals.  */
  69. #define RE_INTERVALS (1 << 7)
  70.  
  71. /* If this bit is not set, then \{ and \} defines an interval,
  72.      and { and } are literals.
  73.    If set, then { and } defines an interval, and \{ and \} are literals.  */
  74. #define RE_NO_BK_BRACES (1 << 8)
  75.  
  76. /* If this bit is set, then character classes are supported.  They are:
  77.      [:alpha:],    [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
  78.      [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
  79.    If not set, then character classes are not supported.  */
  80. #define RE_CHAR_CLASSES (1 << 9)
  81.  
  82. /* If this bit is set, then period doesn't match a null.
  83.    If not set, then it does.  */
  84. #define RE_DOT_NOT_NULL (1 << 10)
  85.  
  86. /* If this bit is set, then [^...] doesn't match a newline.
  87.    If not set, then it does.  */
  88. #define RE_HAT_LISTS_NOT_NEWLINE (1 << 11)
  89.  
  90. /* If this bit is set, then back references are not recognized.
  91.    If not set, then they are.  */
  92. #define RE_NO_BK_REFS (1 << 12)
  93.  
  94. /* If this bit is set, then all back references must refer to a preceding
  95.      subexpression.
  96.    If not set, then a back reference to a nonexistent subexpression is
  97.      treated as literal characters.  */ 
  98. #define RE_NO_MISSING_BK_REF (1 << 13)
  99.  
  100. /* If this bit is set, then *, +, ?, and { cannot be first in an re or
  101.      immediately after OR or BEGINGROUP.  Furthermore, OR cannot be
  102.      first or last in an re, or immediately follow another OR or
  103.      BEGINGROUP.  Also, ^ cannot appear in a nonleading position and $
  104.      cannot appear in a nontrailing position (outside of bracket
  105.      expressions, that is).  */
  106. #define RE_CONTEXT_INVALID_OPS (1 << 14)
  107.  
  108. /* If this bit is set, then +, ? and | aren't recognized as operators.
  109.    If not set, then they are.  */
  110. #define RE_LIMITED_OPS (1 << 15)
  111.  
  112. /* If this bit is set, then an ending range point has to collate higher
  113.      than or equal to the starting range point.
  114.    If not set, then when the ending range point collates higher than the
  115.      starting range point, the range is considered to be empty.  */ 
  116. #define RE_NO_EMPTY_RANGES (1 << 16)
  117.  
  118. /* If this bit is set, then neither the match-beginning-of-line nor
  119.      the match-end-of-line operator match a newline.  
  120.    If not set, then these operators can match a newline.  */
  121. #define RE_NO_ANCHOR_AT_NEWLINE (1 << 17)
  122.  
  123. /* If this bit is set, then you can't have empty groups.
  124.    If not set, then you can.  */
  125. #define RE_NO_EMPTY_GROUPS (1 << 18)
  126.  
  127. /* If this bit is set, then you can't have empty alternatives.
  128.    If not set, then you can.  */
  129. #define RE_NO_EMPTY_ALTS (1 << 19)
  130.  
  131. /* If this bit is set, then you can't have more than one non-interval
  132.      repetition operators (i.e., `*', `+' and `?') in a row, e.g., as in
  133.      `a*+?*'.
  134.    If not set, then you can.  */
  135. #define RE_NO_CONSECUTIVE_REPEATS (1 << 20)
  136.   
  137.  
  138. /* If this bit is set, then ignore anchors inside groups which in turn
  139.      are operated on by repetion operators.
  140.    If not set, then don't.  */
  141. #define RE_REPEATED_ANCHORS_AWAY (1 << 21)
  142.  
  143. /* If this bit is set, then the match-any-character operator (.) matches
  144.      a newline.
  145.    If not set, then it doesn't.  */
  146. #define RE_DOT_NEWLINE (1 << 22)
  147.  
  148. /* If this bit is set, then '^' and '$' can be anchors only at the
  149.      beginning or the end of the pattern. 
  150.    If not set, then they don't have to be at the beginning or end of the
  151.      pattern to be anchors.  */
  152. #define RE_ANCHORS_ONLY_AT_ENDS (1 << 23)
  153.  
  154. /* If this bit is set, then Regex considers an unmatched close-group
  155.      operator to be the ordinary character parenthesis.
  156.    If not set, then an unmatched close-group operator is invalid.  */
  157. #define RE_UNMATCHED_RIGHT_PAREN_ORD (1 << 24)
  158.  
  159. /* If this bit is set, then ^ cannot appear in a nonleading position and
  160.    $ cannot appear in a nontrailing position (outside of bracket
  161.    expressions, that is).  */
  162. #define RE_CONTEXT_INVALID_ANCHORS (1 << 25)
  163.  
  164. /* If this bit is set, then ^ and $ are always anchors, regardless of
  165.      their positions in a regular expression.  
  166.    If this bit is not set, then ^ is an anchor only if in a leading
  167.      position and $ is one only if in a trailing position.  Specifically, 
  168.      
  169.         ^  is in a leading position if at the beginning of a regular
  170.            expression , or after an open-group or an alternation operator;
  171.  
  172.         $  is in a trailing position if at the end of a regular
  173.        expression, or before close-group or an alternation operator.
  174. */
  175. #define RE_CONTEXT_INDEP_ANCHORS (1 << 26)
  176.  
  177. /* If this bit is set, then the searching and matching routines will
  178.      allocate enough register space to accommodate the number of groups
  179.      in the regular expression.
  180.    If this bit is not set, then the user must allocate the space.  */
  181. #define RE_ALLOCATE_REGISTERS (1 << 27)
  182.  
  183.  
  184. /* Define combinations of the above bits for the standard possibilities.  */ 
  185. #define RE_SYNTAX_EMACS 0
  186.  
  187. #define RE_SYNTAX_POSIX_AWK                         \
  188.   (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS        \
  189.    | RE_CONTEXT_INDEP_ANCHORS | RE_ALLOCATE_REGISTERS)
  190.  
  191. #define RE_SYNTAX_AWK                             \
  192.   (RE_SYNTAX_POSIX_AWK | RE_AWK_CLASS_HACK | RE_ALLOCATE_REGISTERS)
  193.  
  194. #define RE_SYNTAX_GREP                             \
  195.   (RE_BK_PLUS_QM | RE_NEWLINE_ALT | RE_ALLOCATE_REGISTERS)
  196.  
  197. #define RE_SYNTAX_EGREP                         \
  198.   (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS         \
  199.    | RE_CONTEXT_INDEP_ANCHORS | RE_NEWLINE_ALT | RE_ALLOCATE_REGISTERS)
  200.  
  201. #define RE_SYNTAX_POSIX_BASIC                        \
  202.   (RE_INTERVALS | RE_CHAR_CLASSES | RE_DOT_NOT_NULL            \
  203.    | RE_NO_MISSING_BK_REF | RE_LIMITED_OPS | RE_NO_EMPTY_RANGES     \
  204.    | RE_NO_ANCHOR_AT_NEWLINE | RE_DOT_NEWLINE | RE_ALLOCATE_REGISTERS)
  205.  
  206. #define RE_SYNTAX_POSIX_EXTENDED                    \
  207.   (RE_INTERVALS | RE_NO_BK_BRACES | RE_NO_BK_VBAR            \
  208.    | RE_NO_BK_PARENS | RE_CHAR_CLASSES | RE_CONTEXT_INVALID_OPS     \
  209.    | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES    | RE_UNMATCHED_RIGHT_PAREN_ORD    \
  210.    | RE_DOT_NOT_NULL | RE_NO_EMPTY_GROUPS | RE_NO_EMPTY_ALTS        \
  211.    | RE_NO_ANCHOR_AT_NEWLINE | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS\
  212.    | RE_ALLOCATE_REGISTERS)
  213.  
  214.  
  215.  
  216. /* Maximum number of duplicates an interval can allow.  */
  217. #define RE_DUP_MAX  ((1 << 15) - 1) 
  218.  
  219.  
  220. /* POSIX cflags bits (i.e., information for regcomp).  */
  221.  
  222. /* If this bit is set, then use extended regular expression syntax.
  223.    If not set, then use basic regular expression syntax.  */
  224. #define REG_EXTENDED 1
  225.  
  226. /* If this bit is set, then (line 526, p.687 of POSIX 1003.2/D10)
  227.      newline loses its special significance; i.e., anchors do not match at
  228.      newlines in the string.
  229.    If not set, then anchors do match at newlines.  */
  230. #define REG_NEWLINE (1 << 1)
  231.  
  232. /* If this bit is set, then ignore case when matching.
  233.    If not set, then case is significant.  */
  234. #define REG_ICASE (1 << 2)
  235.  
  236. /* If this bit is set, then report only success or fail in regexec ().
  237.    If not set, then return nonzero indicating either not match or an error.  */
  238. #define REG_NOSUB (1 << 3)
  239.  
  240.  
  241. /* POSIX eflags bits (i.e., information for regexec).  */
  242.  
  243. /* If this bit is set, then the string's first character is not the
  244.      beginning of a line, so the beginning-of-line anchor shouldn't
  245.      match it.
  246.    If not set, then the string's first character can match the
  247.      beginning-of-line anchor.  */
  248. #define REG_NOTBOL 1
  249.  
  250. /* If this bit is set, then the string's last character is not the
  251.      end of a line, so the end-of-line anchor shouldn't match it.
  252.    If not set, then the string's last character can match the
  253.      end-of-line anchor.  */
  254. #define REG_NOTEOL (1 << 1)
  255.  
  256.  
  257. /* POSIX regexec return error value.  */
  258.  
  259. #define REG_NOMATCH 1    /* Didn't find a match.  */
  260.  
  261. /* POSIX regcomp return error codes.  */
  262.  
  263. #define REG_BADPAT 2    /* Found an invalid pattern.  */
  264. #define REG_ECOLLATE 3  /* Not implemented.  */
  265. #define REG_ECTYPE 4    /* Found an invalid character class name.  */
  266. #define REG_EESCAPE 5     /* Found a trailing backslash.  */
  267. #define REG_ESUBREG 6   /* Found an invalid back reference.  */
  268. #define REG_EBRACK 7    /* Found an unmatched left bracket.  */
  269. #define REG_EPAREN 8     /* Found a parentheses imbalance.  */ 
  270. #define REG_EBRACE 9    /* Found an unmatched \{.  */
  271. #define REG_BADBR 10    /* Found invalid contents of \{\}.  */
  272. #define REG_ERANGE 11     /* Found invalid range end.  */
  273. #define REG_ESPACE 12   /* Ran out of memory.  */
  274. #define REG_BADRPT 13    /* No preceding re for repetition op.  */
  275. #define REG_ENEWLINE 14 /* Not implemented.  */
  276.  
  277. /* Some regcomp codes we've added.  */
  278. #define REG_NOERROR 0    /* No error.  */
  279. #define REG_EEND 15
  280. #define REG_ESIZE 16
  281.  
  282.  
  283.  
  284.  
  285. /* This data structure represents a compiled pattern.  Before calling
  286.    the pattern compiler, the fields `buffer', `allocated', `fastmap',
  287.    `translate', and `no_sub' can be set.  After the pattern has been
  288.    compiled, the `re_nsub' field is available.  All other fields are
  289.    private to the regex routines.  */
  290.  
  291. /* If this changes, change documentation in regex.texinfo.  */
  292.  
  293. struct re_pattern_buffer
  294. {
  295.     /* Space that holds the compiled pattern.  */
  296.   char *buffer;
  297.  
  298.     /* Number of bytes to which `buffer' points.  */
  299.   long allocated;
  300.  
  301.     /* Number of bytes actually used in `buffer'.  */
  302.   long used;    
  303.  
  304.         /* Syntax setting with which the pattern was compiled.  */
  305.   int syntax;
  306.  
  307.         /* Pointer to a fastmap, if any, otherwise zero.  re_search uses
  308.            the fastmap, if there is one, to skip over impossible
  309.            starting points for matches.  */
  310.   char *fastmap;
  311.  
  312.         /* Either a translate table to apply to all characters before
  313.            comparing them, or zero for no translation.  The translation
  314.            is applied to a pattern when it is compiled and to a string
  315.            when it is matched.  */
  316.   char *translate;          
  317.  
  318.     /* Number of subexpressions found by the compiler.  */
  319.   size_t re_nsub;
  320.  
  321.         /* Set to 1 by re_compile_fastmap if this pattern can match the
  322.            null string; 0 prevents the searcher from matching it with
  323.            the null string.  Set to 2 if it might match the null string
  324.            either at the end of a search range or just before a
  325.            character listed in the fastmap.  */
  326.   char can_be_null;
  327.  
  328.  
  329.   /* The remaining fields are all one-bit booleans.  */
  330.   
  331.         /* Set to zero when regex_compile compiles a pattern; set to one
  332.            by re_compile_fastmap when it updates the fastmap, if any.  */
  333.   unsigned fastmap_accurate : 1;
  334.  
  335.         /* If set, regexec reports only success or failure and does not
  336.            return anything in pmatch[].  */
  337.   unsigned no_sub : 1;
  338.  
  339.         /* If set, a beginning-of-line anchor never matches.  */ 
  340.   unsigned not_bol : 1;
  341.  
  342.         /* Similarly for an end-of-line anchor.  */
  343.   unsigned not_eol : 1;
  344.  
  345.         /* If set, and the regs argument is nonzero, the GNU
  346.        matching and searching functions return information 
  347.            for as many registers as needed to report about the 
  348.            whole pattern and all its subexpressions.  If not set, 
  349.            and the regs argument is nonzero, then the functions
  350.            return information for regs->num_regs registers.  */
  351.   unsigned return_default_num_regs : 1;
  352. };
  353.  
  354. typedef struct re_pattern_buffer regex_t;
  355.  
  356.  
  357. /* search.c (search_buffer) in Emacs needs this one value.  It is
  358.    defined both in `regex.c' and here.  */
  359. #define RE_EXACTN_VALUE 1
  360.  
  361.  
  362.  
  363. /* struct re_registers: Structure to store register contents data in.  
  364.  
  365.    (If change comments here, change in regex.texinfo also.)
  366.    
  367.    Some groups in a regular expression match (possibly empty) substrings
  368.    of the string that regular expression matched.  The matcher remembers
  369.    the beginning and ending point of the substring matched by each
  370.    group.  To get what they matched, pass the address of a structure of
  371.    this type to a GNU matching or searching function.
  372.  
  373.    When you call a GNU matching and searching function, it stores
  374.    information into this structure according to the following (in all
  375.    examples below, `(' represents the open-group and `)' the
  376.    close-group operator):
  377.  
  378.    If the regular expression has an i-th group that matches a substring
  379.    of string, then the function sets REGS->start[i] to the index in
  380.    string where the substring matched by the i-th group begins, and
  381.    REGS->end[i] to the index just beyond that substring's end.  The
  382.    function sets REGS->start[0] and REGS->end[0] to analogous
  383.    information about the entire pattern.
  384.  
  385.    For example, when you match the pattern `((a)(b))' with the string
  386.    `ab', you get:
  387.  
  388.       0 in REGS->start[0] and 2 in REGS->end[0] 
  389.       0 in REGS->start[1] and 2 in REGS->end[1] 
  390.       0 in REGS->start[2] and 1 in REGS->end[2] 
  391.       1 in REGS->start[3] and 2 in REGS->end[3] 
  392.  
  393.    If a group matches more than once (as it might if followed by, e.g.,
  394.    a repetition operator), then the function reports the information
  395.    about what the group @emph{last matched.
  396.  
  397.    For example, when you match the string `aa' with the pattern `(a)*',
  398.    you get:
  399.  
  400.       0 in REGS->start[0] and 2 in REGS->end[0] 
  401.       1 in REGS->start[1] and 2 in REGS->end[1] 
  402.  
  403.  
  404.    If the i-th group does not participate in a successful match, e.g.,
  405.    it is an alternative not taken or a repetition operator allows zero
  406.    repetitions of it, then the function sets REGS->start[i] and
  407.    REGS->end[i] to -1.
  408.  
  409.    For example, when you match the string `b' with the pattern `(a)*b',
  410.    you get:
  411.  
  412.       0 in REGS->start[0] and 1 in REGS->end[0] 
  413.       -1 in REGS->start[1] and -1 in REGS->end[1] 
  414.  
  415.  
  416.    If the i-th group matches a zero-length string, then the function
  417.    sets REGS->start[i] and REGS->end[i] to the index just beyond that
  418.    zero-length string.
  419.  
  420.    For example, when you match the string `b' with the pattern `(a*)b',
  421.    you get:
  422.  
  423.       0 in REGS->start[0] and 1 in REGS->end[0] 
  424.       0 in REGS->start[1] and 0 in REGS->end[1] 
  425.  
  426.    The function sets REGS->start[0] and REGS->end[0] to analogous
  427.    information about the entire pattern.
  428.  
  429.    For example, when you match the empty string with the pattern `(a*)',
  430.    you get:
  431.  
  432.       0 in REGS->start[0] and 0 in REGS->end[0] 
  433.       0 in REGS->start[1] and 0 in REGS->end[1] 
  434.  
  435.    If an i-th group contains a j-th group and the function reports a
  436.    match of the i-th group, then it records in REGS->start[j] and
  437.    REGS->end[j] the last match (if it matched) of the j-th group.
  438.  
  439.    For example, when you match the string `abb' with the pattern
  440.    `((a*)b)*, group 2' last matches the empty string, so you get:
  441.  
  442.       0 in REGS->start[0] and 3 in REGS->end[0] 
  443.       2 in REGS->start[1] and 3 in REGS->end[1] 
  444.       2 in REGS->start[2] and 2 in REGS->end[2] 
  445.  
  446.    When you match the string `abb' with the pattern `((a)*b)*', group 2
  447.    doesn't participate in the last match, so you get:
  448.  
  449.       0 in REGS->start[0] and 3 in REGS->end[0] 
  450.       2 in REGS->start[1] and 3 in REGS->end[1] 
  451.       0 in REGS->start[2] and 1 in REGS->end[2] 
  452.  
  453.    If an i-th group contains a j-th group and the function sets
  454.    REGS->start[i] and REGS->end[i] to -1, then it also sets REGS->start[j] 
  455.    and REGS->end[j] to -1.
  456.  
  457.    For example, when you match the string `c' with the pattern
  458.    `((a)*b)*c', you get:
  459.  
  460.       0 in REGS->start[0] and 1 in REGS->end[0] 
  461.       -1 in REGS->start[1] and -1 in REGS->end[1] 
  462.       -1 in REGS->start[2] and -1 in REGS->end[2] 
  463. */
  464.  
  465. struct re_registers
  466. {
  467.   unsigned num_regs;
  468.   int *start;
  469.   int *end;
  470. };
  471.  
  472.  
  473. /* POSIX specification for registers.  See comments for struct
  474.    re_registers for how this is used and read `POSIX' for `GNU',
  475.    `PMATCH' for `REGS', `PMATCH[i].rm_so' for `REGS->start' and
  476.    `PMATCH[i].rm_eo' for `REGS->end'.  */
  477.  
  478. typedef off_t regoff_t;
  479.  
  480. typedef struct
  481. {
  482.   regoff_t rm_so;  /* Byte offset from string's start to substring' start.  */
  483.   regoff_t rm_eo;  /* Byte offset from string's end to substring' end.  */
  484. } regmatch_t;
  485.  
  486.  
  487.  
  488. #ifdef __STDC__
  489.  
  490. /* Compile the regular expression PATTERN, with length LENGTH
  491.    and syntax given by the global `obscure_syntax', into the buffer
  492.    BUFFER.  Return NULL if successful, and an error string if not.  */
  493.  
  494. extern char *re_compile_pattern (const char *pattern, const int length,
  495.                                  struct re_pattern_buffer *buffer);
  496.  
  497.  
  498. /* Compile a fastmap for the compiled pattern in BUFFER; used to
  499.    accelerate searches.  Return 0 if successful and -2 if was an
  500.    internal error.  */
  501.  
  502. extern int re_compile_fastmap (struct re_pattern_buffer *buffer);
  503.  
  504.  
  505. /* Search in the string STRING (with length LENGTH) for the pattern
  506.    compiled into BUFFER.  Start searching at position START, for RANGE
  507.    characters.  Return the starting position of the match or -1 for no
  508.    match, or -2 for an internal error.  Also return register
  509.    information in REGS (if REGS is non-null).  */
  510.  
  511. extern int re_search (struct re_pattern_buffer *buffer,
  512.                       const char *string, const int length,
  513.                       const int start, const int range, 
  514.               struct re_registers *regs);
  515.  
  516. /* Like `re_search', but search in the concatenation of STRING1 and
  517.    STRING2.  Also, stop searching at index START + STOP.  */
  518.  
  519. extern int re_search_2 (struct re_pattern_buffer *buffer,
  520.                         const char *string1, const int length1,
  521.                 const char *string2, const int length2,
  522.                         const int start, const int range, 
  523.                         struct re_registers *regs,
  524.                         const int stop);
  525.  
  526. /* Like `re_search', but return how many characters in STRING the regexp
  527.    in BUFFER matched, starting at position START.  */
  528.  
  529. extern int re_match (const struct re_pattern_buffer *buffer,
  530.                      const char *string, const int length,
  531.                      const int start, struct re_registers *regs);
  532.  
  533.  
  534. /* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
  535.  
  536. extern int re_match_2 (const struct re_pattern_buffer *buffer,
  537.                        const char *string1, const int length1,
  538.                    const char *string2, const int length2,
  539.                        const int start,
  540.                        struct re_registers *regs,
  541.                        const int stop);
  542.  
  543.  
  544. /* 4.2 bsd compatibility.  */
  545. extern char *re_comp (const char *);
  546. extern int re_exec (const char *);
  547.  
  548. extern int regcomp (regex_t *preg, const char *pattern, int cflags);
  549. extern int regexec (const regex_t *preg, const char *string, size_t nmatch,
  550.             regmatch_t pmatch[], int eflags);
  551. extern size_t regerror (int errcode, const regex_t *preg, char* errbuf, 
  552.             size_t errbuf_size);
  553. extern void regfree (regex_t *preg);
  554.  
  555. #else /* not __STDC__ */
  556.  
  557. /* Support old C compilers.  */
  558. #define const
  559.  
  560. extern char *re_compile_pattern ();
  561. extern int re_search (), re_search_2 ();
  562. extern int re_match (), re_match_2 ();
  563.  
  564. /* 4.2 bsd compatibility.  */
  565. extern char *re_comp ();
  566. extern int re_exec ();
  567.  
  568. extern int regcomp ();
  569. extern int regexec ();
  570. extern size_t regerror ();
  571. extern void regfree ();
  572.  
  573. #endif /* __STDC__ */
  574.  
  575.  
  576. #ifdef SYNTAX_TABLE
  577. extern char *re_syntax_table;
  578. #endif
  579.  
  580. #endif /* not __REGEXP_LIBRARY */
  581.  
  582.  
  583.  
  584. /*
  585. Local variables:
  586. make-backup-files: t
  587. version-control: t
  588. trim-versions-without-asking: nil
  589. End:
  590. */
  591.