Commit 0180b1bc authored by Per Cederqvist's avatar Per Cederqvist

This commit was generated by cvs2svn to compensate for changes in r864,

which included commits to RCS files with non-trunk default branches.
parent 0497ad22
Version 0.12
* regex.c does not #define bcmp/bcopy/bzero if they already are.
* regex.h does not redefine `const' if it is already defined, even if
__STDC__ is not defined.
* RE_SYNTAX_ED added (same as POSIX BRE's).
* The following bugs have been fixed, among others:
* The pattern \w+ doesn't infinite loop.
* The pattern ".+\n" is compiled correctly.
* Expressions with more than MAX_REGNUM groups are compiled correctly.
* Patterns that end in a repetition operator (e.g., `*') match
slightly faster if no looping is actually necessary.
Version 0.11 (17 Sep 92)
* Back-references to nonexistent subexpressions, as in the r.e. `abc\1',
......
......@@ -3,9 +3,9 @@ POSIX.2, except for internationalization features.
See the file NEWS for a list of major changes in the current release.
See the file INSTALL for compilation and installation instructions.
(The only thing installed is the documentation; regex.c is compiled into
regex.o, but not installed anywhere.)
See the file INSTALL for compilation instructions. (The only thing
installed is the documentation; regex.c is compiled into regex.o, but
not installed anywhere.)
The subdirectory `doc' contains a (programmers') manual for the library.
It's probably out-of-date. Improvements are welcome.
......
This diff is collapsed.
......@@ -13,11 +13,10 @@ AC_ISC_POSIX
AC_MINIX
AC_STDC_HEADERS
AC_USG
AC_HAVE_HEADERS(string.h)
AC_ALLOCA
dnl We would like to use AC_CONST, but then the test on __STDC__ fails,
dnl and any package which does *not* use AC_CONST loses.
AC_CONST
AC_PREFIX(gcc)
......
......@@ -44,7 +44,7 @@
'xrdef {Anchoring Operators-snt}{Section'tie3.9}
'xrdef {Match-beginning-of-line Operator-pg}{18}
'xrdef {Match-beginning-of-line Operator-snt}{Section'tie3.9.1}
'xrdef {Match-end-of-line Operator-pg}{19}
'xrdef {Match-end-of-line Operator-pg}{18}
'xrdef {Match-end-of-line Operator-snt}{Section'tie3.9.2}
'xrdef {GNU Operators-pg}{20}
'xrdef {GNU Operators-snt}{Chapter'tie4}
......
\initial {$}
\entry {\code {$}}{19}
\entry {\code {$}}{18}
\initial {(}
\entry {\code {(}}{16}
\initial {)}
......@@ -50,43 +50,55 @@
\entry {\samp {{\tt\indexbackslash }w}}{21}
\entry {\samp {{\tt\indexbackslash }W}}{21}
\initial {A}
\entry {\code {allocated \r {initialization}}}{26}
\entry {alternation operator}{13}
\entry {alternation operator and \samp {{\tt\hat}}}{18}
\entry {anchoring}{18}
\entry {anchors}{18, 19}
\entry {anchors}{18}
\entry {Awk}{5}
\initial {B}
\entry {back references}{17}
\entry {backtracking}{10, 13}
\entry {beginning-of-line operator}{18}
\entry {bracket expression}{13}
\entry {\code {buffer \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
\entry {\code {buffer \r {initialization}}}{26}
\initial {C}
\entry {character classes}{14}
\initial {E}
\entry {Egrep}{5}
\entry {Emacs}{5}
\entry {end-of-line operator}{19}
\entry {\code {end\ \r {in\ \code {struct\ re_registers}}}}{32}
\entry {end-of-line operator}{18}
\entry {\code {end\penalty 10000{\spaceskip = 0pt{} }\r {in\penalty 10000{\spaceskip = 0pt{} }\code {struct\penalty 10000{\spaceskip = 0pt{} }re_registers}}}}{32}
\initial {F}
\entry {\code {fastmap \r {initialization}}}{26}
\entry {\code {fastmap{\_}accurate \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
\entry {fastmaps}{30}
\initial {G}
\entry {Grep}{5}
\entry {grouping}{16}
\initial {I}
\entry {ignoring case}{35}
\entry {interval expression}{12}
\initial {M}
\entry {matching list}{13}
\entry {matching newline}{13}
\entry {matching with GNU functions}{27}
\initial {N}
\entry {\code {newline{\_}anchor \r {field in pattern buffer}}}{18}
\entry {nonmatching list}{13}
\entry {\code {not{\_}bol \r {field in pattern buffer}}}{18}
\entry {\code {num_regs\ \r {in\ \code {struct\ re_registers}}}}{32}
\entry {\code {num_regs\penalty 10000{\spaceskip = 0pt{} }\r {in\penalty 10000{\spaceskip = 0pt{} }\code {struct\penalty 10000{\spaceskip = 0pt{} }re_registers}}}}{32}
\initial {O}
\entry {open-group operator and \samp {{\tt\hat}}}{18}
\entry {or operator}{13}
\initial {P}
\entry {parenthesizing}{16}
\entry {pattern buffer initialization}{26}
\entry {pattern buffer, definition of}{24}
\entry {POSIX Awk}{5}
\initial {R}
\entry {\code {range \r {argument to \code {re{\_}search}}}}{28}
\entry {\code {re_registers}}{32}
\entry {\code {RE{\_}BACKSLASH{\_}ESCAPE{\_}IN{\_}LIST}}{3}
\entry {\code {RE{\_}BK{\_}PLUS{\_}QM}}{3}
......@@ -95,7 +107,7 @@
\entry {\code {RE{\_}CONTEXT{\_}INDEP{\_}ANCHORS \r {(and \samp {{\tt\hat}})}}}{18}
\entry {\code {RE{\_}CONTEXT{\_}INDEP{\_}OPS}}{3}
\entry {\code {RE{\_}CONTEXT{\_}INVALID{\_}OPS}}{3}
\entry {\code {RE{\_}DOT{\_}NEWLINE}}{4}
\entry {\code {RE{\_}DOT{\_}NEWLINE}}{3}
\entry {\code {RE{\_}DOT{\_}NOT{\_}NULL}}{4}
\entry {\code {RE{\_}INTERVALS}}{4}
\entry {\code {RE{\_}LIMITED{\_}OPS}}{4}
......@@ -105,21 +117,36 @@
\entry {\code {RE{\_}NO{\_}BK{\_}REFS}}{4}
\entry {\code {RE{\_}NO{\_}BK{\_}VBAR}}{4}
\entry {\code {RE{\_}NO{\_}EMPTY{\_}RANGES}}{4}
\entry {\code {re{\_}pattern{\_}buffer}}{24}
\entry {\code {re{\_}nsub \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
\entry {\code {re{\_}pattern{\_}buffer \r {definition}}}{24}
\entry {\code {re{\_}syntax{\_}options \r {initialization}}}{26}
\entry {\code {RE{\_}UNMATCHED{\_}RIGHT{\_}PAREN{\_}ORD}}{4}
\entry {\code {REG{\_}ICASE}}{36}
\entry {\code {REG{\_}EXTENDED}}{35}
\entry {\code {REG{\_}ICASE}}{35}
\entry {\code {REG{\_}NEWLINE}}{36}
\entry {\code {REG{\_}NOSUB}}{35}
\entry {\code {regex.c}}{1}
\entry {\code {regex.h}}{1}
\entry {regexp anchoring}{18}
\entry {\code {regmatch{\_}t}}{39}
\entry {\code {regs{\_}allocated}}{32}
\entry {\code {REGS{\_}FIXED}}{33}
\entry {\code {REGS{\_}REALLOCATE}}{32}
\entry {\code {REGS{\_}UNALLOCATED}}{32}
\entry {regular expressions, syntax of}{2}
\initial {S}
\entry {\code {start\ \r {in\ \code {struct\ re_registers}}}}{32}
\entry {searching with GNU functions}{28}
\entry {\code {start \r {argument to \code {re{\_}search}}}}{28}
\entry {\code {start\penalty 10000{\spaceskip = 0pt{} }\r {in\penalty 10000{\spaceskip = 0pt{} }\code {struct\penalty 10000{\spaceskip = 0pt{} }re_registers}}}}{32}
\entry {\code {struct re{\_}pattern{\_}buffer \r {definition}}}{24}
\entry {subexpressions}{16}
\entry {syntax bits}{2}
\entry {\code {syntax \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
\entry {syntax initialization}{26}
\entry {syntax of regular expressions}{2}
\initial {T}
\entry {\code {translate \r {initialization}}}{26}
\initial {U}
\entry {\code {used \r {field, set by \code {re{\_}compile{\_}pattern}}}}{27}
\initial {W}
\entry {word boundaries, matching}{20}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Definitions for data structures and routines for the regular
expression library, version 0.11.
expression library, version 0.12.
Copyright (C) 1985, 89, 90, 91, 92 Free Software Foundation, Inc.
Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -20,7 +20,15 @@
#ifndef __REGEXP_LIBRARY_H__
#define __REGEXP_LIBRARY_H__
/* POSIX says that <sys/types.h> must be included before <regex.h>. */
/* POSIX says that <sys/types.h> must be included (by the caller) before
<regex.h>. */
#ifdef VMS
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
should be there. */
#include <stddef.h>
#endif
/* The following bits are used to determine the regexp syntax we
recognize. The set/not-set meanings are chosen so that Emacs syntax
......@@ -137,7 +145,7 @@ extern reg_syntax_t re_syntax_options;
#define RE_SYNTAX_AWK \
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
| RE_NO_BK_VAR | RE_NO_EMPTY_RANGES \
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
| RE_UNMATCHED_RIGHT_PAREN_ORD)
#define RE_SYNTAX_POSIX_AWK \
......@@ -157,6 +165,9 @@ extern reg_syntax_t re_syntax_options;
#define RE_SYNTAX_POSIX_EGREP \
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
/* Syntax bits common to both basic and extended POSIX regex syntax. */
......@@ -311,12 +322,12 @@ struct re_pattern_buffer
#define REGS_FIXED 2
unsigned regs_allocated : 2;
/* Set to zero when regex_compile compiles a pattern; set to one
by re_compile_fastmap when it updates the fastmap, if any. */
/* Set to zero when `regex_compile' compiles a pattern; set to one
by `re_compile_fastmap' if it updates the fastmap. */
unsigned fastmap_accurate : 1;
/* If set, regexec reports only success or failure and does not
return anything in pmatch. */
/* If set, `re_match_2' does not return information about
subexpressions. */
unsigned no_sub : 1;
/* If set, a beginning-of-line anchor doesn't match at the
......@@ -376,16 +387,17 @@ typedef struct
prototype (if we are ANSI), and once without (if we aren't) -- we
use the following macro to declare argument types. This
unfortunately clutters up the declarations a bit, but I think it's
worth it.
We also have to undo `const' if we are not ANSI. */
worth it. */
#if __STDC__
#define _RE_ARGS(args) args
#else
#else /* not __STDC__ */
#define _RE_ARGS(args) ()
#define const
#endif
#endif /* not __STDC__ */
/* Sets the current default syntax to SYNTAX, and return the old syntax.
You can also simply assign to the `re_syntax_options' variable. */
......
/* debugmalloc.c: a malloc for debugging purposes. */
#include <stdio.h>
#include <assert.h>
#include <string.h>
static unsigned trace = 0;
#define TRACE(s) if (trace) fprintf (stderr, "%s", s)
......
......@@ -4,7 +4,7 @@
#define BYTEWIDTH 8
/* Sorry, but this is just a test file. */
/* Sorry, but this is just a test program. */
#define LINE_MAX 500
int
......@@ -57,8 +57,8 @@ main (argc, argv)
while (fgets (line, LINE_MAX, f) != NULL)
{
struct re_registers regs;
size_t len = strlen (line);
struct re_registers regs;
int search_ret
= re_search_2 (&buf, NULL, 0, line, len, 0, len, &regs, len);
......
......@@ -5,6 +5,9 @@
#include <sys/types.h>
#include "regex.h"
/* Don't bother to guess about <string.h> vs <strings.h>, etc. */
extern int strlen ();
#define BYTEWIDTH 8
extern void printchar ();
......@@ -34,12 +37,15 @@ main (argc, argv)
for (;;)
{
char c;
char pat[500] = "", str[500];
char pat[500], str[500];
struct re_registers regs;
/* Some C compilers don't like `char pat[500] = ""'. */
pat[0] = 0;
printf ("Pattern (%s) = ", pat);
gets (pat);
scanstring (pat);
if (feof (stdin))
{
......@@ -62,11 +68,15 @@ main (argc, argv)
i = re_match (&buf, str, strlen (str), 0, &regs);
printf ("Match value %d.\t", i);
print_regs (regs);
if (i >= 0)
print_regs (regs);
putchar ('\n');
i = re_search (&buf, str, strlen (str), 0, strlen (str), &regs);
printf ("Search value %d.\t", i);
print_regs (regs);
if (i >= 0)
print_regs (regs);
putchar ('\n');
}
/* We never get here, but what the heck. */
......@@ -151,6 +161,4 @@ print_regs (regs)
printf ("(%d %d) ", regs.start[i], regs.end[i]);
printf ("%d]", regs.end[0]);
}
putchar ('\n');
}
......@@ -173,7 +173,7 @@ test_regcomp ()
static void
fill_pmatch (pmatch, start0, end0, start1, end1, start2, end2)
regmatch_t pmatch[];
off_t start0, end0, start1, end1, start2, end2;
regoff_t start0, end0, start1, end1, start2, end2;
{
pmatch[0].rm_so = start0;
pmatch[0].rm_eo = end0;
......
......@@ -125,7 +125,9 @@ test_regress ()
{
extern char upcase[];
struct re_pattern_buffer buf;
unsigned len;
struct re_registers regs;
int ret;
char *fastmap = xmalloc (256);
buf.translate = NULL;
......@@ -139,6 +141,14 @@ test_regress ()
test_should_match = true;
re_set_syntax (RE_SYNTAX_EMACS);
/* enami@sys.ptg.sony.co.jp 10 Nov 92 15:19:02 JST */
buf.translate = upcase;
SIMPLE_MATCH ("[A-[]", "A");
buf.translate = NULL;
/* meyering@cs.utexas.edu Nov 6 22:34:41 1992 */
simple_search ("\\w+", "a", 0);
/* jimb@occs.cs.oberlin.edu 10 Sep 92 00:42:33 */
buf.translate = upcase;
SIMPLE_MATCH ("[\001-\377]", "\001");
......@@ -433,6 +443,13 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:");
test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
"two-and-four");
TEST_REGISTERS (":\\(.*\\)", ":/", 0, 2, 1, 2, -1, -1);
/* Bug with `upcase' translation table, from Nico Josuttis
<nico@bredex.de> */
test_should_match = 1;
test_case_fold ("[a-a]", "a");
printf ("\nFinished regression tests.\n");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment