From a620e7d5fb12da44d0e91a5d2f99dcc60d72dd27 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini
Date: Wed, 20 Oct 2004 21:51:12 +0000
Subject: [PATCH] initial ssed import
Patches applied:
* bonzini@gnu.org--2004/sed--stable--4.1--base-0
initial import
git-archimport-id: bonzini@gnu.org--2004b/sed--ssed--3.61--patch-1
---
AUTHORS | 5 +-
BUGS | 6 +
Makefile.am | 14 +-
NEWS | 408 +--
README | 8 +-
TODO | 1 +
bootstrap.sh.in | 10 +
configure.ac | 38 +-
doc/Makefile.am | 2 +-
doc/config.texi | 6 +-
doc/pcre.html | 801 +++++
doc/sed.1 | 18 +-
lib/Makefile.am | 13 +-
lib/regcomp.c | 3793 -----------------------
lib/regex.c | 97 -
lib/regex_.h | 588 ----
lib/regex_internal.c | 1653 ----------
lib/regex_internal.h | 807 -----
lib/regexec.c | 4269 --------------------------
lib/snprintf.c | 337 ++
pcre/AUTHORS | 10 +
pcre/ChangeLog | 283 ++
pcre/ChangeLog.pre-sed | 655 ++++
pcre/LICENCE | 50 +
pcre/Makefile.am | 17 +
pcre/README | 325 ++
pcre/internal.h | 447 +++
pcre/pcre.h | 119 +
pcre/pcregrep.c | 282 ++
pcre/regcomp.c | 1040 +++++++
pcre/regdebug.c | 405 +++
pcre/regexec.c | 2095 +++++++++++++
pcre/regexp.c | 381 +++
pcre/regexp.h | 107 +
pcre/reginfo.c | 111 +
pcre/regperl.c | 2261 ++++++++++++++
pcre/regposix.c | 1921 ++++++++++++
pcre/regstudy.c | 1352 ++++++++
pcre/regsub.c | 242 ++
pcre/regtables.c | 135 +
po/POTFILES.in | 7 +-
po/af.po | 289 +-
po/ca.po | 289 +-
po/cs.po | 274 +-
po/da.po | 289 +-
po/de.po | 289 +-
po/el.po | 286 +-
po/eo.po | 289 +-
po/es.po | 289 +-
po/et.po | 289 +-
po/fi.po | 289 +-
po/fr.po | 289 +-
po/ga.po | 289 +-
po/gl.po | 289 +-
po/he.po | 274 +-
po/hr.po | 280 +-
po/hu.po | 289 +-
po/id.po | 289 +-
po/it.po | 361 ++-
po/ja.po | 289 +-
po/ko.po | 274 +-
po/nl.po | 289 +-
po/pl.po | 289 +-
po/pt_BR.po | 289 +-
po/ro.po | 289 +-
po/ru.po | 289 +-
po/sk.po | 289 +-
po/sl.po | 289 +-
po/sr.po | 289 +-
po/{sed.pot => ssed.pot} | 267 +-
po/sv.po | 289 +-
po/tr.po | 291 +-
po/zh_CN.po | 274 +-
sed/Makefile.am | 6 +-
sed/sed.h | 3 +-
testsuite/BOOST.tests | 829 -----
testsuite/Makefile.am | 28 +-
testsuite/SPENCER.tests | 528 ----
testsuite/bug-regex10.c | 61 -
testsuite/bug-regex11.c | 135 -
testsuite/bug-regex12.c | 73 -
testsuite/bug-regex13.c | 103 -
testsuite/bug-regex14.c | 54 -
testsuite/bug-regex15.c | 47 -
testsuite/bug-regex16.c | 35 -
testsuite/bug-regex21.c | 45 -
testsuite/bug-regex7.c | 92 -
testsuite/bug-regex8.c | 84 -
testsuite/bug-regex9.c | 67 -
testsuite/pcre1.good | 3042 ++++++++++++++++++
testsuite/pcre1.inp | 1964 ++++++++++++
testsuite/pcre1p.good | 3020 ++++++++++++++++++
testsuite/{PCRE.tests => pcre2.good} | 2201 +++++--------
testsuite/pcre2.inp | 928 ++++++
testsuite/pcre2p.good | 1720 +++++++++++
testsuite/pcre3.good | 3011 ++++++++++++++++++
testsuite/pcre3.inp | 1734 +++++++++++
testsuite/pcre3p.good | 2997 ++++++++++++++++++
testsuite/pcretest.c | 1037 +++++++
testsuite/ptestcases.h | 326 --
testsuite/runptests.c | 123 -
testsuite/runtests.c | 138 -
testsuite/testcases.h | 167 -
testsuite/tst-boost.c | 227 --
testsuite/tst-pcre.c | 241 --
testsuite/tst-regex.c | 265 --
testsuite/tst-rxspencer.c | 551 ----
testsuite/version.gin | 4 +-
108 files changed, 41109 insertions(+), 19124 deletions(-)
create mode 100644 TODO
create mode 100644 doc/pcre.html
delete mode 100644 lib/regcomp.c
delete mode 100644 lib/regex.c
delete mode 100644 lib/regex_.h
delete mode 100644 lib/regex_internal.c
delete mode 100644 lib/regex_internal.h
delete mode 100644 lib/regexec.c
create mode 100644 lib/snprintf.c
create mode 100644 pcre/AUTHORS
create mode 100644 pcre/ChangeLog
create mode 100644 pcre/ChangeLog.pre-sed
create mode 100644 pcre/LICENCE
create mode 100644 pcre/Makefile.am
create mode 100644 pcre/README
create mode 100644 pcre/internal.h
create mode 100644 pcre/pcre.h
create mode 100644 pcre/pcregrep.c
create mode 100644 pcre/regcomp.c
create mode 100644 pcre/regdebug.c
create mode 100644 pcre/regexec.c
create mode 100644 pcre/regexp.c
create mode 100644 pcre/regexp.h
create mode 100644 pcre/reginfo.c
create mode 100644 pcre/regperl.c
create mode 100644 pcre/regposix.c
create mode 100644 pcre/regstudy.c
create mode 100644 pcre/regsub.c
create mode 100644 pcre/regtables.c
rename po/{sed.pot => ssed.pot} (67%)
delete mode 100644 testsuite/BOOST.tests
delete mode 100644 testsuite/SPENCER.tests
delete mode 100644 testsuite/bug-regex10.c
delete mode 100644 testsuite/bug-regex11.c
delete mode 100644 testsuite/bug-regex12.c
delete mode 100644 testsuite/bug-regex13.c
delete mode 100644 testsuite/bug-regex14.c
delete mode 100644 testsuite/bug-regex15.c
delete mode 100644 testsuite/bug-regex16.c
delete mode 100644 testsuite/bug-regex21.c
delete mode 100644 testsuite/bug-regex7.c
delete mode 100644 testsuite/bug-regex8.c
delete mode 100644 testsuite/bug-regex9.c
create mode 100644 testsuite/pcre1.good
create mode 100644 testsuite/pcre1.inp
create mode 100644 testsuite/pcre1p.good
rename testsuite/{PCRE.tests => pcre2.good} (50%)
create mode 100644 testsuite/pcre2.inp
create mode 100644 testsuite/pcre2p.good
create mode 100644 testsuite/pcre3.good
create mode 100644 testsuite/pcre3.inp
create mode 100644 testsuite/pcre3p.good
create mode 100644 testsuite/pcretest.c
delete mode 100644 testsuite/ptestcases.h
delete mode 100644 testsuite/runptests.c
delete mode 100644 testsuite/runtests.c
delete mode 100644 testsuite/testcases.h
delete mode 100644 testsuite/tst-boost.c
delete mode 100644 testsuite/tst-pcre.c
delete mode 100644 testsuite/tst-regex.c
delete mode 100644 testsuite/tst-rxspencer.c
diff --git a/AUTHORS b/AUTHORS
index 4474df9..ba54247 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,5 +1,6 @@
-GNU Sed was first authored by Jay Fenlason (hack@gnu.org)
-and later modified by Tom Lord (lord@gnu.org).
+GNU Sed, on which super-sed is based, was first authored by
+Jay Fenlason (hack@gnu.org) and later modified by Tom Lord
+(lord@gnu.org).
It is currently being maintained by Ken Pizzini (ken@gnu.org)
and Paolo Bonzini (bonzini@gnu.org).
diff --git a/BUGS b/BUGS
index 023fa5d..d2e2865 100644
--- a/BUGS
+++ b/BUGS
@@ -26,6 +26,12 @@ for the bug, but that is not a very practical prospect.
+* KNOWN BUGS
+
+The regular expression routines provided must be checked more
+thoroughly against the POSIX.2 standard.
+
+
* NON-BUGS
`N' command on the last line
diff --git a/Makefile.am b/Makefile.am
index f0aaa7f..151b85b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,7 @@ ACLOCAL_AMFLAGS = -I config
PACKAGE = sed
-SUBDIRS = intl lib po sed doc testsuite
+SUBDIRS = intl lib pcre po sed doc testsuite
noinst_DATA = bootstrap.sh
noinst_HEADERS = basicdefs.h
@@ -16,15 +16,3 @@ EXTRA_DIST = BUGS THANKS COPYING.DOC README.boot bootstrap.sh \
html:
cd doc && make html
-
-update-regex:
- cd lib && \
- HOST=sources.redhat.com && \
- BASEURL="http://$$HOST/cgi-bin/cvsweb.cgi/~checkout~/libc/posix" && \
- QUERY='cvsroot=glibc&content-type=text/plain' && \
- wget -O regcomp.c "$$BASEURL/regcomp.c?$$QUERY" && \
- wget -O regexec.c "$$BASEURL/regexec.c?$$QUERY" && \
- wget -O regex.c "$$BASEURL/regex.c?$$QUERY" && \
- wget -O regex_.h "$$BASEURL/regex.h?$$QUERY" && \
- wget -O regex_internal.c "$$BASEURL/regex_internal.c?$$QUERY" && \
- wget -O regex_internal.h "$$BASEURL/regex_internal.h?$$QUERY"
diff --git a/NEWS b/NEWS
index 68329bb..7d1db27 100644
--- a/NEWS
+++ b/NEWS
@@ -1,225 +1,182 @@
-Sed 4.1.3
+Sed 3.61a
-* added a note to BUGS and the manual about changed interpretation
- of `s|abc\|def||'.
+* sed 3.61 had GNU sed 4.1's toplevel Makefile by mistake. Fixed.
-* fixed `make check' in non-English locales.
-
-----------------------------------------------------------------------------
-Sed 4.1.2
-
-* fix bug in 'y' command in multi-byte character sets
-
-* fix severe bug in parsing of ranges with an embedded open bracket
-
-* fix off-by-one error when printing a "bad command" error
-
-----------------------------------------------------------------------------
-Sed 4.1.1
-
-* preserve permissions of in-place edited files
-
-* yield an error when running -i on terminals or other non regular files
-
-* do not interpret - as stdin when running in in-place editing mode
-
-* fix bug that prevented 's' command modifiers from working
-
-----------------------------------------------------------------------------
-Sed 4.1
-
-* // matches the last regular expression even in POSIXLY_CORRECT mode.
-
-* change the way we treat lines which are not terminated by a newline.
-Such lines are printed without the terminating newline (as before)
-but as soon as more text is sent to the same output stream, the
-missing newline is printed, so that the two lines don't concatenate.
-The behavior is now independent from POSIXLY_CORRECT because POSIX
-actually has undefined behavior in this case, and the new implementation
-arguably gives the ``least expected surprise''. Thanks to Stepan
-Kasal for the implementation.
-
-* documentation improvements, with updated references to the POSIX.2
-specification
-
-* error messages on I/O errors are better, and -i does not leave temporary
-files around (e.g. when running ``sed -i'' on a directory).
-
-* escapes are accepted in the y command (for example: y/o/\n/ transforms
-o's into newlines)
-
-* -i option tries to set the owner and group to the same as the input file
-
-* `L' command is deprecated and will be removed in sed 4.2.
-
-* line number addresses are processed differently -- this is supposedly
-conformant to POSIX and surely more idiot-proof. Line number addresses
-are not affected by jumping around them: they are activated and
-deactivated exactly where the script says, while previously
- 5,8b
- 1,5d
-would actually delete lines 1,2,3,4 and 9 (!).
-
-* multibyte characters are taken in consideration to compute the
-operands of s and y, provided you set LC_CTYPE correctly. They are
-also considered by \l, \L, \u, \U, \E.
-
-* [\n] matches either backslash or 'n' when POSIXLY_CORRECT.
-
-* new option --posix, disables all GNU extensions. POSIXLY_CORRECT only
-disables GNU extensions that violate the POSIX standard.
-
-* options -h and -V are not supported anymore, use --help and --version.
-
-* removed documentation for \s and \S which worked incorrectly
-
-* restored correct behavior for \w and \W: match [[:alnum:]_] and
-[^[:alnum:]_] (they used to match [[:alpha:]_] and [^[:alpha:]_]
-
-* the special address 0 can only be used in 0,/RE/ or 0~STEP addresses;
-other cases give an error (you are hindering portability for no reason
-if specifying 0,N and you are giving a dead command if specifying 0
-alone).
-
-* when a \ is used to escape the character that would terminate an operand
-of the s or y commands, the backslash is removed before the regex is
-compiled. This is left undefined by POSIX; this behavior makes `s+x\+++g'
-remove occurrences of `x+', consistently with `s/x\///g'. (However, if
-you enjoy yourself trying `s*x\***g', sed will use the `x*' regex, and you
-won't be able to pass down `x\*' while using * as the delimiter; ideas on
-how to simplify the parser in this respect, and/or gain more coherent
-semantics, are welcome).
-
-
-----------------------------------------------------------------------------
-Sed 4.0.9
+-----------------------------------------------------------------------
+Sed 3.61 (aligned with GNU sed 4.1)
* 0 address behaves correctly in single-file (-i and -s) mode.
-* documentation improvements.
-
-* tested with many hosts and compilers.
-
-* updated regex matcher from upstream, with many bugfixes and speedups.
-
-* the `N' command's feature that is detailed in the BUGS file was disabled
-by the first change below in sed 4.0.8. The behavior has now been
-restored, and is only enabled if POSIXLY_CORRECT behavior is not
-requested.
-
-----------------------------------------------------------------------------
-Sed 4.0.8
-
-* fix `sed n' printing the last line twice.
-
-* fix incorrect error message for invalid character classes.
-
-* fix segmentation violation with repeated empty subexpressions.
-
-* fix incorrect parsing of ^ after escaped (.
-
-* more comprehensive test suite (and with many expected failures...)
-
-----------------------------------------------------------------------------
-Sed 4.0.7
-
-* VPATH builds working on non-glibc machines
-
-* fixed bug in s///Np: was printing even if less than N matches were
-found.
-
-* fixed infinite loop on s///N when LHS matched a null string and
-there were not enough matches in pattern space
-
-* behavior of s///N is consistent with s///g when the LHS can match
-a null string (and the infinite loop did not happen :-)
-
-* updated some translations
-
-----------------------------------------------------------------------------
-Sed 4.0.6
+* // matches the last regular expression even in POSIXLY_CORRECT mode.
* added parameter to `v' for the version of sed that is expected.
+ Also, `v' disables POSIXLY_CORRECT behavior.
-* configure switch --without-included-regex to use the system regex matcher
+* change the way we treat lines which are not terminated by a newline.
+ Such lines are printed without the terminating newline (as before)
+ but as soon as more text is sent to the same output stream, the
+ missing newline is printed, so that the two lines don't concatenate.
+ The behavior is now independent from POSIXLY_CORRECT because POSIX
+ actually has undefined behavior in this case, and the new implementation
+ arguably gives the ``least expected surprise''. Thanks to Stepan
+ Kasal for discussing the issue and providing the implementation.
-* fix for -i option under Cygwin
+* documentation improvements, with updated references to the POSIX.2
+ specification
-----------------------------------------------------------------------------
-Sed 4.0.5
+* error messages on I/O errors are better, and -i does not leave temporary
+ files around (e.g. when running ``sed -i'' on a directory).
-* portability fixes
+* escapes are accepted in the y command (for example: y/o/\n/ transforms
+ o's into newlines)
+
+* fix for -i under Cygwin; also, the -i option tries to set the owner
+ and group to the same as the input file
* improvements to some error messages (e.g. y/abc/defg/ incorrectly said
-`excess characters after command' instead of `y arguments have different
-lengths')
+ `excess characters after command' instead of `y arguments have
+ different lengths')
-* `a', `i', `l', `L', `r' accept two addresses except in POSIXLY_CORRECT
-mode. Only `q' and `Q' do not accept two addresses in standard (GNU) mode.
-
-----------------------------------------------------------------------------
-Sed 4.0.4
-
-* documentation fixes
-
-* update regex matcher
-
-----------------------------------------------------------------------------
-Sed 4.0.3
-
-* fix packaging problem (two missing translation catalogs)
-
-----------------------------------------------------------------------------
-Sed 4.0.2
+* line number addresses are processed differently -- this is supposedly
+ conformant to POSIX and surely more idiot-proof. Line number addresses
+ are not affected by jumping around them: they are activated and
+ deactivated exactly where the script says, while previously
+ 5,8b
+ 1,5d
+ would actually delete lines 1,2,3,4 and 9 (!).
* more translations
-* fix build problems (vpath builds and bootstrap builds)
+* multibyte characters are taken in consideration to compute the
+ operands of s and y, provided you set LC_CTYPE correctly. However,
+ the regular expression matcher does not support them yet.
-----------------------------------------------------------------------------
-Sed 4.0.1
+* new option --posix, disables all extensions. POSIXLY_CORRECT only
+ disables extensions that violate the POSIX standard.
-* Remove last vestiges of super-sed
+* options -h and -V are not supported anymore, use --help and --version.
-* man page automatically built
+* Perl's \G escape is supported both in Perl and POSIX regexps (not in
+ GNU sed).
-* more translations provided
+* portability fixes
-* portability improvements
+* support for [[:blank:]] character class
-----------------------------------------------------------------------------
-Sed 4.0
+* the -i option tries to set the owner and group to the same as the input
+ file
-* Update regex matcher
+* the `L' command is deprecated and will be removed as soon as GNU sed
+ removes it.
-----------------------------------------------------------------------------
-Sed 3.96
+* the `N' command's feature that is detailed in the BUGS file is disabled
+ if POSIXLY_CORRECT behavior is requested.
-* `y' command supports multibyte character sets
+* the special address 0 can only be used in 0,/RE/ or 0~STEP addresses;
+ other cases give an error (you are hindering portability for no reason
+ if specifying 0,N and you are giving a dead command if specifying 0
+ alone).
-* Update regex matcher
+* `a', `i', `l', `L', `r' accept two addresses except in POSIXLY_CORRECT
+ mode. Only `q' and `Q' do not accept two addresses in standard mode.
-----------------------------------------------------------------------------
-Sed 3.95
+* when a \ is used to escape the character that would terminate an operand
+ of the s or y commands, the character loses any meaning as a metacharacter.
+ This is left undefined by POSIX; this behavior makes `s+x\+++g' remove
+ occurrences of `x+', consistently with `s/x\///g'.
+
+-----------------------------------------------------------------------
+Sed 3.60 (aligned with GNU sed 4.0)
+
+* Maintainance release with no visible changes except more translations
+ were added. Limits differences in source code between GNU sed 4.x
+ and ssed.
+
+-----------------------------------------------------------------------
+Sed 3.59
* `R' command reads a single line from a file.
* CR-LF pairs are always ignored under Windows, even if (under Cygwin)
-a disk is mounted as binary.
+ a disk is mounted as binary.
+
+* Fixed bug in the numeric parameter to `s'. The replacement flag
+ was set on the first match of the regular expression, not on the Nth.
+
+* Fixed bug in /.{1,64}/
* More attention to errors on stdout
* New `W' command to write first line of pattern space to a file
+-----------------------------------------------------------------------
+Sed 3.58
+
* Can customize line wrap width on single `l' commands
* `L' command formats and reflows paragraphs like `fmt' does.
+* Upgraded to autoconf 2.53
+
+* When running a script with in-place editing, command ranges such as
+ /abc/,/def/, line numbers, and the special $ address are reset for
+ each file. The same can be done with the new `-s' option when in-
+ place editing is off.
+
+-----------------------------------------------------------------------
+Sed 3.57
+
+* Fixed problems with `-i' when /tmp was on a different volume
+
+* Fixed problems in \[lLuUE] (due to a construct with undefined
+ behavior which some newer compilers optimized away)
+
+-----------------------------------------------------------------------
+Sed 3.56
+
+* Added another "heavy-weight" test (like dc.sed) to the testsuite.
+
+* Bug fix: after using the D command, the first line could have been
+considered valid by a subsequent [GH] command.
+
+* Prune impossible backtracking paths (e.g. b*c does not backtrack
+on b).
+
* The test suite makefiles are better organized (this change is
transparent however).
+-----------------------------------------------------------------------
+Sed 3.55
+
+* Bug fix: Inside a character class, an unrecognized escape sequence
+is interpreted as two separate characters: for example [\g] is a
+character class made of a backslash and a `g'. I thought I had
+fixed this in 3.49, but that fix was not enough.
+
+-----------------------------------------------------------------------
+Sed 3.54
+
+* Bug fix: s/^xxxxx//p did not print (related to the optimization
+introduced by Sed 3.53). This broke Automake 1.5's dependency
+tracking, so if you installed Sed 3.53 as the system sed you should
+configure with --disable-dependency-tracking.
+
+-----------------------------------------------------------------------
+Sed 3.53
+
+* Bug fix: The meanings \` and \' were swapped.
+
* Compiles and bootstraps out-of-the-box under MinGW32 and Cygwin.
+* Faster on most regular expression because it uses the Boyer-Moore
+algorithm to process initial fixed-length strings. The "set of
+possible first characters" algorithm is used as a fallback there
+is no such string (e.g. when a regex starts with a star or question
+mark pattern: [0-9]*).
+
+* Has a comprehensive test suite for both Posix and PERL regular
+expressions.
+
* Optimizes cases when pattern space is truncated at its start or at
its end by `D' or by a substitution command with an empty RHS.
For example scripts like this,
@@ -229,15 +186,53 @@ For example scripts like this,
whose behavior was quadratic with previous versions of sed, have
now linear behavior.
+------------------------------------------------------------------------
+Sed 3.52
+
+* Merged with PCRE 3.7:
+
+** pcre_exec() was referring to its "code" argument before testing
+that argument for NULL (and giving an error if it was NULL).
+
+** The limit of 200 on non-capturing parentheses is a _nesting_ limit,
+not an absolute limit. Changed the text of the error message to make
+this clear, and likewise updated the man page.
+
+** The limit of 99 on the number of capturing subpatterns has been
+removed.
+
* New command `e' to pipe the output of a command into the output
of sed.
* New option `e' to pass the output of the `s' command through the
Bourne shell and get the result into pattern space.
+* Simple minded optimization in the matcher: if the regexp is
+anchored to the end of the pattern, and the regexp cannot match
+more than some number of characters, leap to the end of pattern
+space minus that number of characters. For example, abc[def]$
+will start matching four characters before the end of pattern
+space.
+
* Switched to obstacks in the parser -- less memory-related bugs
(there were none AFAIK but you never know) and less memory usage.
+------------------------------------------------------------------------
+Sed 3.51
+
+* Bug fix: behavior of undefined regular expressions (such as a single
+star `*') is more consistent with GNU sed and does not issue
+internal errors anymore.
+
+* Bug fix: fixed internal error when backslashed expressions appeared
+inside character classes (e.g. [\X]). This broke autoconf 2.50 or
+later.
+
+------------------------------------------------------------------------
+Sed 3.50
+
+* Updated to latest autoconf and automake.
+
* New option -i, to support in-place editing a la Perl. Usually one
had to use ed or, for more complex tasks, resort to Perl; this is
not necessary anymore.
@@ -249,23 +244,59 @@ not definitive, though.
* Bug fix: Made the behavior of s/A*/x/g (i.e. `s' command with a
possibly empty LHS) more consistent:
- pattern GNU sed 3.x GNU sed 4.x
+ pattern 3.49 or GNU sed 3.50
B xBx xBx
BC xBxCx xBxCx
BAC xBxxCx xBxCx
BAAC xBxxCx xBxCx
+Earlier versions matched a spurious empty string after the sequence
+of A's.
+
+------------------------------------------------------------------------
+Sed 3.49
+
+* Bug fix: Inside a character class, an unrecognized escape sequence
+is interpreted as two separate characters: for example [\g] is a
+character class made of a backslash and a `g'. This change is
+needed for compatibility with autoconf 2.50.
+
+------------------------------------------------------------------------
+Sed 3.48
+
+* Bug fix: on the RHS of the `s' command, the syntax of the octal
+constants is the same as for Perl. Note that it is not possible
+yet to specify more than 9 backreferences on the RHS of the `s'
+command.
+
+* Bug fix: \c is parsed on the RHS of the `s' command.
+
+* Bug fix: the q and Q commands could be misinterpreted, leading to
+spurious syntax errors in the following command
+
* Bug fix: the // empty regular expressions now refers to the last
regular expression that was matched, rather than to the last
regular expression that was compiled. This richer behavior seems
to be the correct one (albeit neither one is POSIXLY_CORRECT).
-* Check for invalid backreferences in the RHS of the `s' command
-(e.g. s/1234/\1/)
+------------------------------------------------------------------------
+Sed 3.47
-* Support for \[lLuUE] in the RHS of the `s' command like in Perl.
+* This version adds a check for invalid backreferences in the
+RHS of the `s' command (e.g. s/1234/\1/) and support for
+\[lLuUE] in the RHS of the `s' command like in Perl.
-* New regular expression matcher
+------------------------------------------------------------------------
+Sed 3.46
+
+* This version is not an official GNU release, hence it is dubbed
+`super-sed' and uses a strange version number unlikely to clash
+with GNU sed's numbering. It is my hope to merge super-sed's
+changes with GNU sed one day, but at the moment they should be
+considered separate programs at all effects.
+
+* It uses a different regular expression matcher which is much more
+faster (6x to 20x), especially on backreferences.
* Bug fix: if a file was redirected to be stdin, sed did not consume
it. So
@@ -277,19 +308,24 @@ double-spaced TESTFILE, while the equivalent `useless use of cat'
printed nothing (which is the correct behavior). A test for this
bug was added to the test suite.
+* A bug in the test suite (the khadafy test was run with BREs instead
+of EREs) has been corrected.
+
* The documentation is now much better, with a few examples provided,
and a thorough description of regular expressions. The manual often
refers to "GNU extensions", but if they are described here they are
specific to this version.
-* Documented command-line option:
+* Added new command-line options:
-r, --regexp-extended
Use extended regexps -- e.g. (abc+) instead of \(abc\+\)
+ -R, --regexp-perl
+ Use Perl regexps (\l, \L, \u, \U, \E not supported)
* Added feature to the `w' command and to the `w' option of the `s'
command: if the file name is /dev/stderr, it means the standard
-error (inspired by awk); and similarly for /dev/stdout. This is
-disabled if POSIXLY_CORRECT is set.
+error (inspired by awk). This is disabled if POSIXLY_CORRECT is
+set.
* Added `m' and `M' modifiers to `s' command for multi-line
matching (Perl-style); in addresses, only `M' works.
@@ -300,7 +336,9 @@ an exit code from a sed script to the caller.
* Added `T' command for `branch if failed'.
* Added `v' command, which is a do-nothing intended to fail on
-seds that do not support GNU sed 4.0's extensions.
+seds that do not support super-sed's extensions.
+
+* Bootstrapping was tested and is known to work.
----------------------------------------------------------------------------
Sed 3.02.80
diff --git a/README b/README
index 3da31c2..4926ea0 100644
--- a/README
+++ b/README
@@ -1,7 +1,9 @@
-This is the GNU implementation of sed, the Unix stream editor.
+This is a version of sed based on GNU sed. It is not
+a version of GNU sed, though.
-See the NEWS file for a brief summary and the ChangeLog for
-more detailed descriptions of changes.
+There are several new features, including extended regular expression
+syntax, and some bug fixes; see the NEWS file for a brief summary
+and the ChangeLog for more detailed descriptions of changes.
See the file INSTALL for generic compilation and installation
instructions.
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..6428e4d
--- /dev/null
+++ b/TODO
@@ -0,0 +1 @@
+* Make pcre/reg{perl,posix}.c handle [[=x=]] and [[.x.]] and MBCS
diff --git a/bootstrap.sh.in b/bootstrap.sh.in
index 82b2432..5146490 100755
--- a/bootstrap.sh.in
+++ b/bootstrap.sh.in
@@ -71,6 +71,16 @@ ${CC} -DHAVE_CONFIG_H -I.. -I. -c regex.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c strerror.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -c utils.c || exit 1
+cd ../pcre || exit 1
+${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c regdebug.c || exit 1
+${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c regexp.c || exit 1
+${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c reginfo.c || exit 1
+${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c regperl.c || exit 1
+${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c regposix.c || exit 1
+${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c regstudy.c || exit 1
+${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c regsub.c || exit 1
+${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c regtables.c || exit 1
+
cd ../sed || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c sed.c || exit 1
${CC} -DHAVE_CONFIG_H -I.. -I. -I../lib -c fmt.c || exit 1
diff --git a/configure.ac b/configure.ac
index e08c9a3..61f60cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
dnl Process this file with -*- autoconf -*- to produce a configure script.
-AC_INIT(sed, 4.1.2, bonzini@gnu.org, sed)
+AC_INIT(sed, 3.61, bonzini@gnu.org, ssed)
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR([sed/sed.c])
AM_CONFIG_HEADER(config.h:config_h.in)
@@ -66,37 +66,15 @@ AC_FUNC_OBSTACK
AC_FUNC_MBRTOWC
AC_TYPE_MBSTATE_T
gl_FUNC_STRVERSCMP
-AC_REPLACE_FUNCS(memchr memcmp memmove strerror mkstemp)
+AC_REPLACE_FUNCS(memchr memcmp memmove strerror snprintf mkstemp)
AC_CHECK_FUNCS(isatty bcopy bzero isascii memcpy memset strchr strtoul popen \
pathconf isblank fchown fchmod setlocale wcrtomb wcscoll btowc)
-AC_ARG_WITH(included-regex,
-[ --with-included-regex use included regex matcher (default=yes)], ,
-with_included_regex=yes)
-
-AC_ARG_ENABLE(regex-tests,
-[ --enable-regex-tests enable regex matcher regression tests (default=no)], ,
-enable_regex_tests=no)
-
-if test "x$with_included_regex" = xno; then
- AC_CHECK_HEADERS(regex.h)
- AC_CHECK_LIB(regex, re_search)
- AC_CHECK_FUNC(re_search)
- if test $ac_cv_header_regex_h = no || test $ac_cv_func_re_search = no; then
- AC_MSG_WARN([GNU regex not found, falling back to the included version])
- with_included_regex=yes
- fi
-fi
-
-if test "x$with_included_regex" = xno; then
- enable_regex_tests=no
-fi
-
-AM_CONDITIONAL(TEST_REGEX, test "x$enable_regex_tests" != xno)
-if test "x$with_included_regex" != xno; then
- AC_CONFIG_LINKS(lib/regex.h:lib/regex_.h)
- AC_LIBOBJ(regex)
-fi
+AC_ARG_ENABLE(pcregrep,
+[ --enable-pcregrep build the pcregrep test program],
+PCREGREP=pcregrep,
+PCREGREP=)
+AC_SUBST(PCREGREP)
AC_ARG_ENABLE(html,
[ --enable-html build HTML manual (default=no)], ,
@@ -135,5 +113,5 @@ AM_GNU_GETTEXT(, need-ngettext)
AC_CONFIG_FILES([bootstrap.sh], chmod +x bootstrap.sh)
AC_CONFIG_FILES([Makefile doc/Makefile \
lib/Makefile sed/Makefile testsuite/Makefile \
-po/Makefile.in intl/Makefile])
+po/Makefile.in intl/Makefile pcre/Makefile])
AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
index d96c2fa..a3be449 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -2,7 +2,7 @@
info_TEXINFOS = sed.texi
sed_TEXINFOS = config.texi version.texi
dist_man_MANS = sed.1
-dist_noinst_DATA = sed.x sed-in.texi
+dist_noinst_DATA = sed.x sed-in.texi pcre.html
dist_noinst_SCRIPTS = groupify.sed
CLEANFILES = sed.html
TEXI2DVI = $(top_srcdir)/config/texi2dvi --expand
diff --git a/doc/config.texi b/doc/config.texi
index aa5e35a..91d1526 100644
--- a/doc/config.texi
+++ b/doc/config.texi
@@ -4,6 +4,6 @@
@end direntry
-@clear PERL
-@set SSEDEXT @acronym{GNU} extensions
-@set SSED @acronym{GNU} @command{sed}
+@set PERL
+@set SSEDEXT @acronym{ssed} extensions
+@set SSED @command{super-sed}
diff --git a/doc/pcre.html b/doc/pcre.html
new file mode 100644
index 0000000..f3a2d0b
--- /dev/null
+++ b/doc/pcre.html
@@ -0,0 +1,801 @@
+
+
+pcre specification
+
+
+pcre specification
+
+NAME
+
+pcre - Perl-compatible regular expressions.
+
+SYNOPSIS
+
+#include <pcre.h>
+
+
+pcre *pcre_compile(const char *pattern, int options,
+const char **errptr, int *erroffset,
+const unsigned char *tableptr);
+
+
+pcre_extra *pcre_study(const pcre *code, int options,
+const char **errptr);
+
+
+int pcre_exec(const pcre *code, const pcre_extra *extra,
+const char *subject, int length, int startoffset,
+int options, int *ovector, int ovecsize);
+
+
+int pcre_copy_substring(const char *subject, int *ovector,
+int stringcount, int stringnumber, char *buffer,
+int buffersize);
+
+
+int pcre_get_substring(const char *subject, int *ovector,
+int stringcount, int stringnumber,
+const char **stringptr);
+
+
+int pcre_get_substring_list(const char *subject,
+int *ovector, int stringcount, const char ***listptr);
+
+
+void pcre_free_substring(const char *stringptr);
+
+
+void pcre_free_substring_list(const char **stringptr);
+
+
+const unsigned char *pcre_maketables(void);
+
+
+int pcre_info(const pcre *code, const pcre_extra *extra,
+int what, void *where);
+
+
+void *(*pcre_malloc)(size_t);
+
+
+void (*pcre_free)(void *);
+
+DESCRIPTION
+
+The PCRE library is a set of functions that implement regular expression
+pattern matching using the same syntax and semantics as Perl 5, with just a few
+differences (see below). The current implementation corresponds to Perl 5.005,
+with some additional features from later versions. This includes some
+experimental, incomplete support for UTF-8 encoded strings. Details of exactly
+what is and what is not supported are given below.
+
+
+PCRE has its own native API, which is described in this document. There is also
+a set of wrapper functions that correspond to the POSIX regular expression API.
+These are described in the pcreposix documentation.
+
+
+The native API function prototypes are defined in the header file pcre.h,
+and on Unix systems the library itself is called libpcre.a, so can be
+accessed by adding -lpcre to the command for linking an application which
+calls it. The header file defines the macros PCRE_MAJOR and PCRE_MINOR to
+contain the major and minor release numbers for the library. Applications can
+use these to include support for different releases.
+
+
+The functions pcre_compile(), pcre_study(), and pcre_exec()
+are used for compiling and matching regular expressions.
+
+
+The functions pcre_copy_substring(), pcre_get_substring(), and
+pcre_get_substring_list() are convenience functions for extracting
+captured substrings from a matched subject string; pcre_free_substring()
+and pcre_free_substring_list() are also provided, to free the memory used
+for extracted strings.
+
+
+The function pcre_maketables() is used (optionally) to build a set of
+character tables in the current locale for passing to pcre_compile().
+
+
+The function pcre_info() is used to find out information about a
+compiled pattern.
+
+
+The global variables pcre_malloc and pcre_free initially contain
+the entry points of the standard malloc() and free() functions
+respectively. PCRE calls the memory management functions via these variables,
+so a calling program can replace them if it wishes to intercept the calls. This
+should be done before calling any PCRE functions.
+
+MULTI-THREADING
+
+The PCRE functions can be used in multi-threading applications, with the
+proviso that the memory management functions pointed to by pcre_malloc
+and pcre_free are shared by all threads.
+
+
+The compiled form of a regular expression is not altered during matching, so
+the same compiled pattern can safely be used by several threads at once.
+
+COMPILING A PATTERN
+
+The function pcre_compile() is called to compile a pattern into an
+internal form. The pattern is a C string terminated by a binary zero, and
+is passed in the argument pattern. A pointer to a single block of memory
+that is obtained via pcre_malloc is returned. This contains the
+compiled code and related data. The pcre type is defined for this for
+convenience, but in fact pcre is just a typedef for void, since the
+contents of the block are not externally defined. It is up to the caller to
+free the memory when it is no longer required.
+
+
+The size of a compiled pattern is roughly proportional to the length of the
+pattern string, except that each character class (other than those containing
+just a single character, negated or not) requires 33 bytes, and repeat
+quantifiers with a minimum greater than one or a bounded maximum cause the
+relevant portions of the compiled pattern to be replicated.
+
+
+The options argument contains independent bits that affect the
+compilation. It should be zero if no options are required. Some of the options,
+in particular, those that are compatible with Perl, can also be set and unset
+from within the pattern (see the detailed description of regular expressions
+below). For these options, the contents of the options argument specifies
+their initial settings at the start of compilation and execution. The
+PCRE_ANCHORED option can be set at the time of matching as well as at compile
+time.
+
+
+If errptr is NULL, pcre_compile() returns NULL immediately.
+Otherwise, if compilation of a pattern fails, pcre_compile() returns
+NULL, and sets the variable pointed to by errptr to point to a textual
+error message. The offset from the start of the pattern to the character where
+the error was discovered is placed in the variable pointed to by
+erroffset, which must not be NULL. If it is, an immediate error is given.
+
+
+If the final argument, tableptr, is NULL, PCRE uses a default set of
+character tables which are built when it is compiled, using the default C
+locale. Otherwise, tableptr must be the result of a call to
+pcre_maketables(). See the section on locale support below.
+
+
+The following option bits are defined in the header file:
+
+
+
+ PCRE_ANCHORED
+
+
+
+If this bit is set, the pattern is forced to be "anchored", that is, it is
+constrained to match only at the start of the string which is being searched
+(the "subject string"). This effect can also be achieved by appropriate
+constructs in the pattern itself, which is the only way to do it in Perl.
+
+
+
+ PCRE_CASELESS
+
+
+
+If this bit is set, letters in the pattern match both upper and lower case
+letters. It is equivalent to Perl's /i option.
+
+
+
+ PCRE_DOLLAR_ENDONLY
+
+
+
+If this bit is set, a dollar metacharacter in the pattern matches only at the
+end of the subject string. Without this option, a dollar also matches
+immediately before the final character if it is a newline (but not before any
+other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is
+set. There is no equivalent to this option in Perl.
+
+
+
+ PCRE_DOTALL
+
+
+
+If this bit is set, a dot metacharater in the pattern matches all characters,
+including newlines. Without it, newlines are excluded. This option is
+equivalent to Perl's /s option. A negative class such as [^a] always matches a
+newline character, independent of the setting of this option.
+
+
+
+ PCRE_EXTENDED
+
+
+
+If this bit is set, whitespace data characters in the pattern are totally
+ignored except when escaped or inside a character class, and characters between
+an unescaped # outside a character class and the next newline character,
+inclusive, are also ignored. This is equivalent to Perl's /x option, and makes
+it possible to include comments inside complicated patterns. Note, however,
+that this applies only to data characters. Whitespace characters may never
+appear within special character sequences in a pattern, for example within the
+sequence (?( which introduces a conditional subpattern.
+
+
+
+ PCRE_EXTRA
+
+
+
+This option was invented in order to turn on additional functionality of PCRE
+that is incompatible with Perl, but it is currently of very little use. When
+set, any backslash in a pattern that is followed by a letter that has no
+special meaning causes an error, thus reserving these combinations for future
+expansion. By default, as in Perl, a backslash followed by a letter with no
+special meaning is treated as a literal. There are at present no other features
+controlled by this option. It can also be set by a (?X) option setting within a
+pattern.
+
+
+
+ PCRE_MULTILINE
+
+
+
+By default, PCRE treats the subject string as consisting of a single "line" of
+characters (even if it actually contains several newlines). The "start of line"
+metacharacter (^) matches only at the start of the string, while the "end of
+line" metacharacter ($) matches only at the end of the string, or before a
+terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
+Perl.
+
+
+When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
+match immediately following or immediately before any newline in the subject
+string, respectively, as well as at the very start and end. This is equivalent
+to Perl's /m option. If there are no "\n" characters in a subject string, or
+no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no
+effect.
+
+
+
+ PCRE_UNGREEDY
+
+
+
+This option inverts the "greediness" of the quantifiers so that they are not
+greedy by default, but become greedy if followed by "?". It is not compatible
+with Perl. It can also be set by a (?U) option setting within the pattern.
+
+
+
+ PCRE_UTF8
+
+
+
+This option causes PCRE to regard both the pattern and the subject as strings
+of UTF-8 characters instead of just byte strings. However, it is available only
+if PCRE has been built to include UTF-8 support. If not, the use of this option
+provokes an error. Support for UTF-8 is new, experimental, and incomplete.
+Details of exactly what it entails are given below.
+
+STUDYING A PATTERN
+
+When a pattern is going to be used several times, it is worth spending more
+time analyzing it in order to speed up the time taken for matching. The
+function pcre_study() takes a pointer to a compiled pattern as its first
+argument, and returns a pointer to a pcre_extra block (another void
+typedef) containing additional information about the pattern; this can be
+passed to pcre_exec(). If no additional information is available, NULL
+is returned.
+
+
+The second argument contains option bits. At present, two options are
+defined for pcre_study(), PCRE_STUDY_NO_PRUNE and PCRE_STUDY_NO_START,
+which skip one of the available regex-studying algorithms.
+
+
+The third argument for pcre_study() is a pointer to an error message. If
+studying succeeds (even if no data is returned), the variable it points to is
+set to NULL. Otherwise it points to a textual error message.
+
+
+Studying a pattern is very useful for non-anchored patterns that do
+not have a single fixed starting character or that start with a fixed-length
+(no stars) pattern, because in this case PCRE builds data structures that
+allow the matcher to skip several characters when looking for a place to
+start matching. This study can be inhibited by PCRE_STUDY_NO_START.
+
+
+In addition, when PCRE_STUDY_NO_PRUNE is not specified, pcre_study()
+tries to cut backtracking paths by looking for constructs such as [^;]*;
+or \d*\. (if digits are to be followed by a period, which is not a digit,
+there's no use in backtracking). This often can limit the exponential
+behavior of the matcher and speed up failing attempts to match a pattern.
+
+LOCALE SUPPORT
+
+PCRE handles caseless matching, and determines whether characters are letters,
+digits, or whatever, by reference to a set of tables. The library contains a
+default set of tables which is created in the default C locale when PCRE is
+compiled. This is used when the final argument of pcre_compile() is NULL,
+and is sufficient for many applications.
+
+
+An alternative set of tables can, however, be supplied. Such tables are built
+by calling the pcre_maketables() function, which has no arguments, in the
+relevant locale. The result can then be passed to pcre_compile() as often
+as necessary. For example, to build and use tables that are appropriate for the
+French locale (where accented characters with codes greater than 128 are
+treated as letters), the following code could be used:
+
+
+
+ setlocale(LC_CTYPE, "fr");
+ tables = pcre_maketables();
+ re = pcre_compile(..., tables);
+
+
+
+The tables are built in memory that is obtained via pcre_malloc. The
+pointer that is passed to pcre_compile is saved with the compiled
+pattern, and the same tables are used via this pointer by pcre_study()
+and pcre_exec(). Thus for any single pattern, compilation, studying and
+matching all happen in the same locale, but different patterns can be compiled
+in different locales. It is the caller's responsibility to ensure that the
+memory containing the tables remains available for as long as it is needed.
+
+INFORMATION ABOUT A PATTERN
+
+The pcre_fullinfo() function returns information about a compiled
+pattern. The first argument for pcre_fullinfo() is a pointer to the
+compiled pattern. The second argument is the result of pcre_study(),
+or NULL if the pattern was not studied. The third argument specifies which
+piece of information is required, while the fourth argument is a pointer to a
+variable to receive the data. The yield of the function is zero for success,
+or one of the following negative numbers:
+
+
+
+ PCRE_ERROR_NULL the argument code was NULL
+ the argument where was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+ PCRE_ERROR_BADOPTION the value of what was invalid
+
+
+
+The possible values for the third argument are defined in pcre.h, and are
+as follows:
+
+
+
+ PCRE_INFO_OPTIONS
+
+
+
+Return a copy of the options with which the pattern was compiled. The fourth
+argument should point to au unsigned long int variable. These option bits
+are those specified in the call to pcre_compile(), modified by any
+top-level option settings within the pattern itself, and with the PCRE_ANCHORED
+bit forcibly set if the form of the pattern implies that it can match only at
+the start of a subject string.
+
+
+
+ PCRE_INFO_SIZE
+
+
+
+Return the size of the compiled pattern, that is, the value that was passed as
+the argument to pcre_malloc() when PCRE was getting memory in which to
+place the compiled data. The fourth argument should point to a size_t
+variable.
+
+
+
+ PCRE_INFO_CAPTURECOUNT
+
+
+
+Return the number of capturing subpatterns in the pattern. The fourth argument
+should point to an \fbint\fR variable.
+
+
+
+ PCRE_INFO_BACKREFMAX
+
+
+
+Return the number of the highest back reference in the pattern. The fourth
+argument should point to an int variable. Zero is returned if there are
+no back references.
+
+
+
+ PCRE_INFO_FIRSTCHAR
+
+
+
+Return information about the first character of any matched string, for a
+non-anchored pattern. If there is a fixed first character, e.g. from a pattern
+such as (cat|cow|coyote), it is returned in the integer pointed to by
+where. Otherwise, if either
+
+
+(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
+starts with "^", or
+
+
+(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
+(if it were set, the pattern would be anchored),
+
+
+-1 is returned, indicating that the pattern matches only at the start of a
+subject string or after any "\n" within the string. Otherwise -2 is returned.
+For anchored patterns, -2 is returned.
+
+
+
+ PCRE_INFO_FIRSTTABLE
+
+
+
+If the pattern was studied, and this resulted in the construction of a 256-bit
+table indicating a fixed set of characters for the first character in any
+matching string, a pointer to the table is returned. Otherwise NULL is
+returned. The fourth argument should point to an unsigned char *
+variable.
+
+
+
+ PCRE_INFO_LASTLITERAL
+
+
+
+For a non-anchored pattern, return the value of the rightmost literal character
+which must exist in any matched string, other than at its start. The fourth
+argument should point to an int variable. If there is no such character,
+or if the pattern is anchored, -1 is returned. For example, for the pattern
+/a\d+z\d+/ the returned value is 'z'.
+
+
+
+MATCHING A PATTERN
+
+The function pcre_exec() is called to match a subject string against a
+pre-compiled pattern, which is passed in the code argument. If the
+pattern has been studied, the result of the study should be passed in the
+extra argument. Otherwise this must be NULL.
+
+
+The PCRE_ANCHORED option can be passed in the options argument, whose
+unused bits must be zero. However, if a pattern was compiled with
+PCRE_ANCHORED, or turned out to be anchored by virtue of its contents, it
+cannot be made unachored at matching time.
+
+
+There are also three further options that can be set only at matching time:
+
+
+
+ PCRE_NOTBOL
+
+
+
+The first character of the string is not the beginning of a line, so the
+circumflex metacharacter should not match before it. Setting this without
+PCRE_MULTILINE (at compile time) causes circumflex never to match.
+
+
+
+ PCRE_NOTEOL
+
+
+
+The end of the string is not the end of a line, so the dollar metacharacter
+should not match it nor (except in multiline mode) a newline immediately before
+it. Setting this without PCRE_MULTILINE (at compile time) causes dollar never
+to match.
+
+
+
+ PCRE_NOTEMPTY
+
+
+
+An empty string is not considered to be a valid match if this option is set. If
+there are alternatives in the pattern, they are tried. If all the alternatives
+match the empty string, the entire match fails. For example, if the pattern
+
+
+
+ a?b?
+
+
+
+is applied to a string not beginning with "a" or "b", it matches the empty
+string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
+valid, so PCRE searches further into the string for occurrences of "a" or "b".
+
+
+Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case
+of a pattern match of the empty string within its split() function, and
+when using the /g modifier. It is possible to emulate Perl's behaviour after
+matching a null string by first trying the match again at the same offset with
+PCRE_NOTEMPTY set, and then if that fails by advancing the starting offset (see
+below) and trying an ordinary match again.
+
+
+The subject string is passed as a pointer in subject, a length in
+length, and a starting offset in startoffset. Unlike the pattern
+string, it may contain binary zero characters. When the starting offset is
+zero, the search for a match starts at the beginning of the subject, and this
+is by far the most common case.
+
+
+A non-zero starting offset is useful when searching for another match in the
+same subject by calling pcre_exec() again after a previous success.
+Setting startoffset differs from just passing over a shortened string and
+setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
+lookbehind. For example, consider the pattern
+
+
+
+ \Biss\B
+
+
+
+which finds occurrences of "iss" in the middle of words. (\B matches only if
+the current position in the subject is not a word boundary.) When applied to
+the string "Mississipi" the first call to pcre_exec() finds the first
+occurrence. If pcre_exec() is called again with just the remainder of the
+subject, namely "issipi", it does not match, because \B is always false at the
+start of the subject, which is deemed to be a word boundary. However, if
+pcre_exec() is passed the entire string again, but with startoffset
+set to 4, it finds the second occurrence of "iss" because it is able to look
+behind the starting point to discover that it is preceded by a letter.
+
+
+If a non-zero starting offset is passed when the pattern is anchored, one
+attempt to match at the given offset is tried. This can only succeed if the
+pattern does not require the match to be at the start of the subject.
+
+
+In general, a pattern matches a certain portion of the subject, and in
+addition, further substrings from the subject may be picked out by parts of the
+pattern. Following the usage in Jeffrey Friedl's book, this is called
+"capturing" in what follows, and the phrase "capturing subpattern" is used for
+a fragment of a pattern that picks out a substring. PCRE supports several other
+kinds of parenthesized subpattern that do not cause substrings to be captured.
+
+
+Captured substrings are returned to the caller via a vector of integer offsets
+whose address is passed in ovector. The number of elements in the vector
+is passed in ovecsize. The first two-thirds of the vector is used to pass
+back captured substrings, each substring using a pair of integers. The
+remaining third of the vector is used as workspace by pcre_exec() while
+matching capturing subpatterns, and is not available for passing back
+information. The length passed in ovecsize should always be a multiple of
+three. If it is not, it is rounded down.
+
+
+When a match has been successful, information about captured substrings is
+returned in pairs of integers, starting at the beginning of ovector, and
+continuing up to two-thirds of its length at the most. The first element of a
+pair is set to the offset of the first character in a substring, and the second
+is set to the offset of the first character after the end of a substring. The
+first pair, ovector[0] and ovector[1], identify the portion of the
+subject string matched by the entire pattern. The next pair is used for the
+first capturing subpattern, and so on. The value returned by pcre_exec()
+is the number of pairs that have been set. If there are no capturing
+subpatterns, the return value from a successful match is 1, indicating that
+just the first pair of offsets has been set.
+
+
+Some convenience functions are provided for extracting the captured substrings
+as separate strings. These are described in the following section.
+
+
+It is possible for an capturing subpattern number n+1 to match some
+part of the subject when subpattern n has not been used at all. For
+example, if the string "abc" is matched against the pattern (a|(z))(bc)
+subpatterns 1 and 3 are matched, but 2 is not. When this happens, both offset
+values corresponding to the unused subpattern are set to -1.
+
+
+If a capturing subpattern is matched repeatedly, it is the last portion of the
+string that it matched that gets returned.
+
+
+If the vector is too small to hold all the captured substrings, it is used as
+far as possible (up to two-thirds of its length), and the function returns a
+value of zero. In particular, if the substring offsets are not of interest,
+pcre_exec() may be called with ovector passed as NULL and
+ovecsize as zero. However, if the pattern contains back references and
+the ovector isn't big enough to remember the related substrings, PCRE has
+to get additional memory for use during matching. Thus it is usually advisable
+to supply an ovector.
+
+
+Note that pcre_info() can be used to find out how many capturing
+subpatterns there are in a compiled pattern. The smallest size for
+ovector that will allow for n captured substrings in addition to
+the offsets of the substring matched by the whole pattern is (n+1)*3.
+
+
+If pcre_exec() fails, it returns a negative number. The following are
+defined in the header file:
+
+
+
+ PCRE_ERROR_NOMATCH (-1)
+
+
+
+The subject string did not match the pattern.
+
+
+
+ PCRE_ERROR_NULL (-2)
+
+
+
+Either code or subject was passed as NULL, or ovector was
+NULL and ovecsize was not zero.
+
+
+
+ PCRE_ERROR_BADOPTION (-3)
+
+
+
+An unrecognized bit was set in the options argument.
+
+
+
+ PCRE_ERROR_BADMAGIC (-4)
+
+
+
+PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
+the case when it is passed a junk pointer. This is the error it gives when the
+magic number isn't present.
+
+
+
+ PCRE_ERROR_UNKNOWN_NODE (-5)
+
+
+
+While running the pattern match, an unknown item was encountered in the
+compiled pattern. This error could be caused by a bug in PCRE or by overwriting
+of the compiled pattern.
+
+
+
+ PCRE_ERROR_NOMEMORY (-6)
+
+
+
+If a pattern contains back references, but the ovector that is passed to
+pcre_exec() is not big enough to remember the referenced substrings, PCRE
+gets a block of memory at the start of matching to use for this purpose. If the
+call via pcre_malloc() fails, this error is given. The memory is freed at
+the end of matching.
+
+EXTRACTING CAPTURED SUBSTRINGS
+
+Captured substrings can be accessed directly by using the offsets returned by
+pcre_exec() in ovector. For convenience, the functions
+pcre_copy_substring(), pcre_get_substring(), and
+pcre_get_substring_list() are provided for extracting captured substrings
+as new, separate, zero-terminated strings. A substring that contains a binary
+zero is correctly extracted and has a further zero added on the end, but the
+result does not, of course, function as a C string.
+
+
+The first three arguments are the same for all three functions: subject
+is the subject string which has just been successfully matched, ovector
+is a pointer to the vector of integer offsets that was passed to
+pcre_exec(), and stringcount is the number of substrings that
+were captured by the match, including the substring that matched the entire
+regular expression. This is the value returned by pcre_exec if it
+is greater than zero. If pcre_exec() returned zero, indicating that it
+ran out of space in ovector, the value passed as stringcount should
+be the size of the vector divided by three.
+
+
+The functions pcre_copy_substring() and pcre_get_substring()
+extract a single substring, whose number is given as stringnumber. A
+value of zero extracts the substring that matched the entire pattern, while
+higher values extract the captured substrings. For pcre_copy_substring(),
+the string is placed in buffer, whose length is given by
+buffersize, while for pcre_get_substring() a new block of memory is
+obtained via pcre_malloc, and its address is returned via
+stringptr. The yield of the function is the length of the string, not
+including the terminating zero, or one of
+
+
+
+ PCRE_ERROR_NOMEMORY (-6)
+
+
+
+The buffer was too small for pcre_copy_substring(), or the attempt to get
+memory failed for pcre_get_substring().
+
+
+
+ PCRE_ERROR_NOSUBSTRING (-7)
+
+
+
+There is no substring whose number is stringnumber.
+
+
+The pcre_get_substring_list() function extracts all available substrings
+and builds a list of pointers to them. All this is done in a single block of
+memory which is obtained via pcre_malloc. The address of the memory block
+is returned via listptr, which is also the start of the list of string
+pointers. The end of the list is marked by a NULL pointer. The yield of the
+function is zero if all went well, or
+
+
+
+ PCRE_ERROR_NOMEMORY (-6)
+
+
+
+if the attempt to get the memory block failed.
+
+
+When any of these functions encounter a substring that is unset, which can
+happen when capturing subpattern number n+1 matches some part of the
+subject, but subpattern n has not been used at all, they return an empty
+string. This can be distinguished from a genuine zero-length substring by
+inspecting the appropriate offset in ovector, which is negative for unset
+substrings.
+
+
+The two convenience functions pcre_free_substring() and
+pcre_free_substring_list() can be used to free the memory returned by
+a previous call of pcre_get_substring() or
+pcre_get_substring_list(), respectively. They do nothing more than call
+the function pointed to by pcre_free, which of course could be called
+directly from a C program. However, PCRE is used in some situations where it is
+linked via a special interface to another programming language which cannot use
+pcre_free directly; it is for these cases that the functions are
+provided.
+
+AUTHOR
+
+Philip Hazel <ph10@cam.ac.uk>
+
+University Computing Service,
+
+New Museums Site,
+
+Cambridge CB2 3QG, England.
+
+Phone: +44 1223 334714
+
+
+Last updated: 28 August 2000,
+
+
+ the 250th anniversary of the death of J.S. Bach.
+
+
+Copyright (c) 1997-2000 University of Cambridge.
diff --git a/doc/sed.1 b/doc/sed.1
index 2b9c88c..cbab033 100644
--- a/doc/sed.1
+++ b/doc/sed.1
@@ -1,7 +1,7 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28.
-.TH SED "1" "August 2004" "sed version 4.1.2" "User Commands"
+.TH SUPER-SED "1" "March 2004" "super-sed version 3.61" "User Commands"
.SH NAME
-sed \- manual page for sed version 4.1.2
+super-sed \- manual page for super-sed version 3.61
.SH SYNOPSIS
.B sed
[\fIOPTION\fR]... \fI{script-only-if-no-other-script} \fR[\fIinput-file\fR]...
@@ -19,7 +19,7 @@ input(s), and is consequently more efficient.
But it is \*(sd's ability to filter text in a pipeline
which particularly distinguishes it from other types of
editors.
-.HP
+.PP
\fB\-n\fR, \fB\-\-quiet\fR, \fB\-\-silent\fR
.IP
suppress automatic printing of pattern space
@@ -48,6 +48,10 @@ disable all GNU extensions.
.IP
use extended regular expressions in the script.
.HP
+\fB\-R\fR, \fB\-\-regexp\-perl\fR
+.IP
+use Perl 5's regular expressions syntax in the script.
+.HP
\fB\-s\fR, \fB\-\-separate\fR
.IP
consider files as separate rather than as a single continuous
@@ -70,7 +74,9 @@ remaining arguments are names of input files; if no input files are
specified, then the standard input is read.
.PP
E-mail bug reports to: bonzini@gnu.org .
-Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
+Be sure to include the word ``ssed'' somewhere in the ``Subject:'' field.
+.PP
+based on GNU sed version 4.1
.SH "COMMAND SYNOPSIS"
This is just a brief synopsis of \*(sd commands to serve as
a reminder to those who already know \*(sd;
@@ -362,11 +368,11 @@ the \*(sd FAQ (http://sed.sf.net/grabbag/tutorials/sedfaq.html),
http://sed.sf.net/grabbag/.
.PP
The full documentation for
-.B sed
+.B super-sed
is maintained as a Texinfo manual. If the
.B info
and
-.B sed
+.B super-sed
programs are properly installed at your site, the command
.IP
.B info sed
diff --git a/lib/Makefile.am b/lib/Makefile.am
index d3a153f..1bc1d1c 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,16 +1,15 @@
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = libsed.a
-noinst_HEADERS = getopt.h utils.h obstack.h regex_.h regex_internal.h \
- strverscmp.h stdbool_.h
+noinst_HEADERS = getopt.h utils.h obstack.h strverscmp.h \
+ stdbool_.h
libsed_a_SOURCES = getopt1.c getopt.c utils.c
+EXTRA_DIST = memmove.c strerror.c
-EXTRA_DIST = memmove.c strerror.c regcomp.c regexec.c regex_internal.c
-
-AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/intl -I$(top_srcdir) \
- -I$(top_builddir)/lib
+AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/intl -I$(top_srcdir)/pcre \
+ -I$(top_srcdir)
libsed_a_LIBADD = @LIBOBJS@ @ALLOCA@
libsed_a_DEPENDENCIES = $(libsed_a_LIBADD)
-DISTCLEANFILES = regex.h stdbool.h
+DISTCLEANFILES = stdbool.h
diff --git a/lib/regcomp.c b/lib/regcomp.c
deleted file mode 100644
index 96b63a4..0000000
--- a/lib/regcomp.c
+++ /dev/null
@@ -1,3793 +0,0 @@
-/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Isamu Hasegawa .
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
- int length, reg_syntax_t syntax);
-static void re_compile_fastmap_iter (regex_t *bufp,
- const re_dfastate_t *init_state,
- char *fastmap);
-static reg_errcode_t init_dfa (re_dfa_t *dfa, int pat_len);
-static void init_word_char (re_dfa_t *dfa);
-#ifdef RE_ENABLE_I18N
-static void free_charset (re_charset_t *cset);
-#endif /* RE_ENABLE_I18N */
-static void free_workarea_compile (regex_t *preg);
-static reg_errcode_t create_initial_state (re_dfa_t *dfa);
-#ifdef RE_ENABLE_I18N
-static void optimize_utf8 (re_dfa_t *dfa);
-#endif
-static reg_errcode_t analyze (re_dfa_t *dfa);
-static reg_errcode_t analyze_tree (re_dfa_t *dfa, bin_tree_t *node);
-static void calc_first (re_dfa_t *dfa, bin_tree_t *node);
-static void calc_next (re_dfa_t *dfa, bin_tree_t *node);
-static void calc_epsdest (re_dfa_t *dfa, bin_tree_t *node);
-static reg_errcode_t duplicate_node_closure (re_dfa_t *dfa, int top_org_node,
- int top_clone_node, int root_node,
- unsigned int constraint);
-static reg_errcode_t duplicate_node (int *new_idx, re_dfa_t *dfa, int org_idx,
- unsigned int constraint);
-static int search_duplicated_node (re_dfa_t *dfa, int org_node,
- unsigned int constraint);
-static reg_errcode_t calc_eclosure (re_dfa_t *dfa);
-static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa,
- int node, int root);
-static void calc_inveclosure (re_dfa_t *dfa);
-static int fetch_number (re_string_t *input, re_token_t *token,
- reg_syntax_t syntax);
-static void fetch_token (re_token_t *result, re_string_t *input,
- reg_syntax_t syntax);
-static int peek_token (re_token_t *token, re_string_t *input,
- reg_syntax_t syntax);
-static int peek_token_bracket (re_token_t *token, re_string_t *input,
- reg_syntax_t syntax);
-static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
- reg_syntax_t syntax, reg_errcode_t *err);
-static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
- re_token_t *token, reg_syntax_t syntax,
- int nest, reg_errcode_t *err);
-static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg,
- re_token_t *token, reg_syntax_t syntax,
- int nest, reg_errcode_t *err);
-static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg,
- re_token_t *token, reg_syntax_t syntax,
- int nest, reg_errcode_t *err);
-static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg,
- re_token_t *token, reg_syntax_t syntax,
- int nest, reg_errcode_t *err);
-static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp,
- re_dfa_t *dfa, re_token_t *token,
- reg_syntax_t syntax, reg_errcode_t *err);
-static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa,
- re_token_t *token, reg_syntax_t syntax,
- reg_errcode_t *err);
-static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
- re_string_t *regexp,
- re_token_t *token, int token_len,
- re_dfa_t *dfa,
- reg_syntax_t syntax,
- int accept_hyphen);
-static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
- re_string_t *regexp,
- re_token_t *token);
-#ifndef _LIBC
-# ifdef RE_ENABLE_I18N
-static reg_errcode_t build_range_exp (re_bitset_ptr_t sbcset,
- re_charset_t *mbcset, int *range_alloc,
- bracket_elem_t *start_elem,
- bracket_elem_t *end_elem);
-static reg_errcode_t build_collating_symbol (re_bitset_ptr_t sbcset,
- re_charset_t *mbcset,
- int *coll_sym_alloc,
- const unsigned char *name);
-# else /* not RE_ENABLE_I18N */
-static reg_errcode_t build_range_exp (re_bitset_ptr_t sbcset,
- bracket_elem_t *start_elem,
- bracket_elem_t *end_elem);
-static reg_errcode_t build_collating_symbol (re_bitset_ptr_t sbcset,
- const unsigned char *name);
-# endif /* not RE_ENABLE_I18N */
-#endif /* not _LIBC */
-#ifdef RE_ENABLE_I18N
-static reg_errcode_t build_equiv_class (re_bitset_ptr_t sbcset,
- re_charset_t *mbcset,
- int *equiv_class_alloc,
- const unsigned char *name);
-static reg_errcode_t build_charclass (unsigned RE_TRANSLATE_TYPE trans,
- re_bitset_ptr_t sbcset,
- re_charset_t *mbcset,
- int *char_class_alloc,
- const unsigned char *class_name,
- reg_syntax_t syntax);
-#else /* not RE_ENABLE_I18N */
-static reg_errcode_t build_equiv_class (re_bitset_ptr_t sbcset,
- const unsigned char *name);
-static reg_errcode_t build_charclass (unsigned RE_TRANSLATE_TYPE trans,
- re_bitset_ptr_t sbcset,
- const unsigned char *class_name,
- reg_syntax_t syntax);
-#endif /* not RE_ENABLE_I18N */
-static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
- unsigned RE_TRANSLATE_TYPE trans,
- const unsigned char *class_name,
- const unsigned char *extra,
- int non_match, reg_errcode_t *err);
-static bin_tree_t *create_tree (re_dfa_t *dfa,
- bin_tree_t *left, bin_tree_t *right,
- re_token_type_t type, int index);
-static bin_tree_t *re_dfa_add_tree_node (re_dfa_t *dfa,
- bin_tree_t *left, bin_tree_t *right,
- const re_token_t *token)
- __attribute ((noinline));
-static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa);
-static void mark_opt_subexp (const bin_tree_t *src, re_dfa_t *dfa);
-static void mark_opt_subexp_iter (const bin_tree_t *src, re_dfa_t *dfa, int idx);
-
-/* This table gives an error message for each of the error codes listed
- in regex.h. Obviously the order here has to be same as there.
- POSIX doesn't require that we do anything for REG_NOERROR,
- but why not be nice? */
-
-const char __re_error_msgid[] attribute_hidden =
- {
-#define REG_NOERROR_IDX 0
- gettext_noop ("Success") /* REG_NOERROR */
- "\0"
-#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
- gettext_noop ("No match") /* REG_NOMATCH */
- "\0"
-#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match")
- gettext_noop ("Invalid regular expression") /* REG_BADPAT */
- "\0"
-#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
- gettext_noop ("Invalid collation character") /* REG_ECOLLATE */
- "\0"
-#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
- gettext_noop ("Invalid character class name") /* REG_ECTYPE */
- "\0"
-#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name")
- gettext_noop ("Trailing backslash") /* REG_EESCAPE */
- "\0"
-#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash")
- gettext_noop ("Invalid back reference") /* REG_ESUBREG */
- "\0"
-#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
- gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */
- "\0"
-#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^")
- gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
- "\0"
-#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
- gettext_noop ("Unmatched \\{") /* REG_EBRACE */
- "\0"
-#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{")
- gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */
- "\0"
-#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
- gettext_noop ("Invalid range end") /* REG_ERANGE */
- "\0"
-#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end")
- gettext_noop ("Memory exhausted") /* REG_ESPACE */
- "\0"
-#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted")
- gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */
- "\0"
-#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
- gettext_noop ("Premature end of regular expression") /* REG_EEND */
- "\0"
-#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression")
- gettext_noop ("Regular expression too big") /* REG_ESIZE */
- "\0"
-#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big")
- gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
- };
-
-const size_t __re_error_msgid_idx[] attribute_hidden =
- {
- REG_NOERROR_IDX,
- REG_NOMATCH_IDX,
- REG_BADPAT_IDX,
- REG_ECOLLATE_IDX,
- REG_ECTYPE_IDX,
- REG_EESCAPE_IDX,
- REG_ESUBREG_IDX,
- REG_EBRACK_IDX,
- REG_EPAREN_IDX,
- REG_EBRACE_IDX,
- REG_BADBR_IDX,
- REG_ERANGE_IDX,
- REG_ESPACE_IDX,
- REG_BADRPT_IDX,
- REG_EEND_IDX,
- REG_ESIZE_IDX,
- REG_ERPAREN_IDX
- };
-
-/* Entry points for GNU code. */
-
-/* re_compile_pattern is the GNU regular expression compiler: it
- compiles PATTERN (of length LENGTH) and puts the result in BUFP.
- Returns 0 if the pattern was valid, otherwise an error string.
-
- Assumes the `allocated' (and perhaps `buffer') and `translate' fields
- are set in BUFP on entry. */
-
-const char *
-re_compile_pattern (pattern, length, bufp)
- const char *pattern;
- size_t length;
- struct re_pattern_buffer *bufp;
-{
- reg_errcode_t ret;
-
- /* And GNU code determines whether or not to get register information
- by passing null for the REGS argument to re_match, etc., not by
- setting no_sub. */
- bufp->no_sub = 0;
-
- /* Match anchors at newline. */
- bufp->newline_anchor = 1;
-
- ret = re_compile_internal (bufp, pattern, length, re_syntax_options);
-
- if (!ret)
- return NULL;
- return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
-}
-#ifdef _LIBC
-weak_alias (__re_compile_pattern, re_compile_pattern)
-#endif
-
-/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
- also be assigned to arbitrarily: each pattern buffer stores its own
- syntax, so it can be changed between regex compilations. */
-/* This has no initializer because initialized variables in Emacs
- become read-only after dumping. */
-reg_syntax_t re_syntax_options;
-
-
-/* Specify the precise syntax of regexps for compilation. This provides
- for compatibility for various utilities which historically have
- different, incompatible syntaxes.
-
- The argument SYNTAX is a bit mask comprised of the various bits
- defined in regex.h. We return the old syntax. */
-
-reg_syntax_t
-re_set_syntax (syntax)
- reg_syntax_t syntax;
-{
- reg_syntax_t ret = re_syntax_options;
-
- re_syntax_options = syntax;
- return ret;
-}
-#ifdef _LIBC
-weak_alias (__re_set_syntax, re_set_syntax)
-#endif
-
-int
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
-{
- re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
- char *fastmap = bufp->fastmap;
-
- memset (fastmap, '\0', sizeof (char) * SBC_MAX);
- re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
- if (dfa->init_state != dfa->init_state_word)
- re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap);
- if (dfa->init_state != dfa->init_state_nl)
- re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
- if (dfa->init_state != dfa->init_state_begbuf)
- re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
- bufp->fastmap_accurate = 1;
- return 0;
-}
-#ifdef _LIBC
-weak_alias (__re_compile_fastmap, re_compile_fastmap)
-#endif
-
-static inline void
-__attribute ((always_inline))
-re_set_fastmap (char *fastmap, int icase, int ch)
-{
- fastmap[ch] = 1;
- if (icase)
- fastmap[tolower (ch)] = 1;
-}
-
-/* Helper function for re_compile_fastmap.
- Compile fastmap for the initial_state INIT_STATE. */
-
-static void
-re_compile_fastmap_iter (bufp, init_state, fastmap)
- regex_t *bufp;
- const re_dfastate_t *init_state;
- char *fastmap;
-{
- re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
- int node_cnt;
- int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
- for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
- {
- int node = init_state->nodes.elems[node_cnt];
- re_token_type_t type = dfa->nodes[node].type;
-
- if (type == CHARACTER)
- {
- re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
-#ifdef RE_ENABLE_I18N
- if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
- {
- unsigned char *buf = alloca (dfa->mb_cur_max), *p;
- wchar_t wc;
- mbstate_t state;
-
- p = buf;
- *p++ = dfa->nodes[node].opr.c;
- while (++node < dfa->nodes_len
- && dfa->nodes[node].type == CHARACTER
- && dfa->nodes[node].mb_partial)
- *p++ = dfa->nodes[node].opr.c;
- memset (&state, 0, sizeof (state));
- if (mbrtowc (&wc, (const char *) buf, p - buf,
- &state) == p - buf
- && __wcrtomb ((char *) buf, towlower (wc), &state) > 0)
- re_set_fastmap (fastmap, 0, buf[0]);
- }
-#endif
- }
- else if (type == SIMPLE_BRACKET)
- {
- int i, j, ch;
- for (i = 0, ch = 0; i < BITSET_UINTS; ++i)
- for (j = 0; j < UINT_BITS; ++j, ++ch)
- if (dfa->nodes[node].opr.sbcset[i] & (1 << j))
- re_set_fastmap (fastmap, icase, ch);
- }
-#ifdef RE_ENABLE_I18N
- else if (type == COMPLEX_BRACKET)
- {
- int i;
- re_charset_t *cset = dfa->nodes[node].opr.mbcset;
- if (cset->non_match || cset->ncoll_syms || cset->nequiv_classes
- || cset->nranges || cset->nchar_classes)
- {
-# ifdef _LIBC
- if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0)
- {
- /* In this case we want to catch the bytes which are
- the first byte of any collation elements.
- e.g. In da_DK, we want to catch 'a' since "aa"
- is a valid collation element, and don't catch
- 'b' since 'b' is the only collation element
- which starts from 'b'. */
- int j, ch;
- const int32_t *table = (const int32_t *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
- for (i = 0, ch = 0; i < BITSET_UINTS; ++i)
- for (j = 0; j < UINT_BITS; ++j, ++ch)
- if (table[ch] < 0)
- re_set_fastmap (fastmap, icase, ch);
- }
-# else
- if (dfa->mb_cur_max > 1)
- for (i = 0; i < SBC_MAX; ++i)
- if (__btowc (i) == WEOF)
- re_set_fastmap (fastmap, icase, i);
-# endif /* not _LIBC */
- }
- for (i = 0; i < cset->nmbchars; ++i)
- {
- char buf[256];
- mbstate_t state;
- memset (&state, '\0', sizeof (state));
- __wcrtomb (buf, cset->mbchars[i], &state);
- re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
- if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
- {
- __wcrtomb (buf, towlower (cset->mbchars[i]), &state);
- re_set_fastmap (fastmap, 0, *(unsigned char *) buf);
- }
- }
- }
-#endif /* RE_ENABLE_I18N */
- else if (type == OP_PERIOD
-#ifdef RE_ENABLE_I18N
- || type == OP_UTF8_PERIOD
-#endif /* RE_ENABLE_I18N */
- || type == END_OF_RE)
- {
- memset (fastmap, '\1', sizeof (char) * SBC_MAX);
- if (type == END_OF_RE)
- bufp->can_be_null = 1;
- return;
- }
- }
-}
-
-/* Entry point for POSIX code. */
-/* regcomp takes a regular expression as a string and compiles it.
-
- PREG is a regex_t *. We do not expect any fields to be initialized,
- since POSIX says we shouldn't. Thus, we set
-
- `buffer' to the compiled pattern;
- `used' to the length of the compiled pattern;
- `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
- REG_EXTENDED bit in CFLAGS is set; otherwise, to
- RE_SYNTAX_POSIX_BASIC;
- `newline_anchor' to REG_NEWLINE being set in CFLAGS;
- `fastmap' to an allocated space for the fastmap;
- `fastmap_accurate' to zero;
- `re_nsub' to the number of subexpressions in PATTERN.
-
- PATTERN is the address of the pattern string.
-
- CFLAGS is a series of bits which affect compilation.
-
- If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
- use POSIX basic syntax.
-
- If REG_NEWLINE is set, then . and [^...] don't match newline.
- Also, regexec will try a match beginning after every newline.
-
- If REG_ICASE is set, then we considers upper- and lowercase
- versions of letters to be equivalent when matching.
-
- If REG_NOSUB is set, then when PREG is passed to regexec, that
- routine will report only success or failure, and nothing about the
- registers.
-
- It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
- the return codes and their meanings.) */
-
-int
-regcomp (preg, pattern, cflags)
- regex_t *__restrict preg;
- const char *__restrict pattern;
- int cflags;
-{
- reg_errcode_t ret;
- reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
- : RE_SYNTAX_POSIX_BASIC);
-
- preg->buffer = NULL;
- preg->allocated = 0;
- preg->used = 0;
-
- /* Try to allocate space for the fastmap. */
- preg->fastmap = re_malloc (char, SBC_MAX);
- if (BE (preg->fastmap == NULL, 0))
- return REG_ESPACE;
-
- syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
-
- /* If REG_NEWLINE is set, newlines are treated differently. */
- if (cflags & REG_NEWLINE)
- { /* REG_NEWLINE implies neither . nor [^...] match newline. */
- syntax &= ~RE_DOT_NEWLINE;
- syntax |= RE_HAT_LISTS_NOT_NEWLINE;
- /* It also changes the matching behavior. */
- preg->newline_anchor = 1;
- }
- else
- preg->newline_anchor = 0;
- preg->no_sub = !!(cflags & REG_NOSUB);
- preg->translate = NULL;
-
- ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);
-
- /* POSIX doesn't distinguish between an unmatched open-group and an
- unmatched close-group: both are REG_EPAREN. */
- if (ret == REG_ERPAREN)
- ret = REG_EPAREN;
-
- /* We have already checked preg->fastmap != NULL. */
- if (BE (ret == REG_NOERROR, 1))
- /* Compute the fastmap now, since regexec cannot modify the pattern
- buffer. This function never fails in this implementation. */
- (void) re_compile_fastmap (preg);
- else
- {
- /* Some error occurred while compiling the expression. */
- re_free (preg->fastmap);
- preg->fastmap = NULL;
- }
-
- return (int) ret;
-}
-#ifdef _LIBC
-weak_alias (__regcomp, regcomp)
-#endif
-
-/* Returns a message corresponding to an error code, ERRCODE, returned
- from either regcomp or regexec. We don't use PREG here. */
-
-size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- const regex_t *preg;
- char *errbuf;
- size_t errbuf_size;
-{
- const char *msg;
- size_t msg_size;
-
- if (BE (errcode < 0
- || errcode >= (int) (sizeof (__re_error_msgid_idx)
- / sizeof (__re_error_msgid_idx[0])), 0))
- /* Only error codes returned by the rest of the code should be passed
- to this routine. If we are given anything else, or if other regex
- code generates an invalid error code, then the program has a bug.
- Dump core so we can fix it. */
- abort ();
-
- msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
-
- msg_size = strlen (msg) + 1; /* Includes the null. */
-
- if (BE (errbuf_size != 0, 1))
- {
- if (BE (msg_size > errbuf_size, 0))
- {
-#if defined HAVE_MEMPCPY || defined _LIBC
- *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
-#else
- memcpy (errbuf, msg, errbuf_size - 1);
- errbuf[errbuf_size - 1] = 0;
-#endif
- }
- else
- memcpy (errbuf, msg, msg_size);
- }
-
- return msg_size;
-}
-#ifdef _LIBC
-weak_alias (__regerror, regerror)
-#endif
-
-
-static void
-free_dfa_content (re_dfa_t *dfa)
-{
- int i, j;
-
- re_free (dfa->subexps);
-
- if (dfa->nodes)
- for (i = 0; i < dfa->nodes_len; ++i)
- {
- re_token_t *node = dfa->nodes + i;
-#ifdef RE_ENABLE_I18N
- if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
- free_charset (node->opr.mbcset);
- else
-#endif /* RE_ENABLE_I18N */
- if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
- re_free (node->opr.sbcset);
- }
- re_free (dfa->nexts);
- for (i = 0; i < dfa->nodes_len; ++i)
- {
- if (dfa->eclosures != NULL)
- re_node_set_free (dfa->eclosures + i);
- if (dfa->inveclosures != NULL)
- re_node_set_free (dfa->inveclosures + i);
- if (dfa->edests != NULL)
- re_node_set_free (dfa->edests + i);
- }
- re_free (dfa->edests);
- re_free (dfa->eclosures);
- re_free (dfa->inveclosures);
- re_free (dfa->nodes);
-
- if (dfa->state_table)
- for (i = 0; i <= dfa->state_hash_mask; ++i)
- {
- struct re_state_table_entry *entry = dfa->state_table + i;
- for (j = 0; j < entry->num; ++j)
- {
- re_dfastate_t *state = entry->array[j];
- free_state (state);
- }
- re_free (entry->array);
- }
- re_free (dfa->state_table);
-#ifdef RE_ENABLE_I18N
- re_free (dfa->sb_char);
-#endif
-#ifdef DEBUG
- re_free (dfa->re_str);
-#endif
-
- re_free (dfa);
-}
-
-
-/* Free dynamically allocated space used by PREG. */
-
-void
-regfree (preg)
- regex_t *preg;
-{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
- if (BE (dfa != NULL, 1))
- free_dfa_content (dfa);
- preg->buffer = NULL;
- preg->allocated = 0;
-
- re_free (preg->fastmap);
- preg->fastmap = NULL;
-
- re_free (preg->translate);
- preg->translate = NULL;
-}
-#ifdef _LIBC
-weak_alias (__regfree, regfree)
-#endif
-
-/* Entry points compatible with 4.2 BSD regex library. We don't define
- them unless specifically requested. */
-
-#if defined _REGEX_RE_COMP || defined _LIBC
-
-/* BSD has one and only one pattern buffer. */
-static struct re_pattern_buffer re_comp_buf;
-
-char *
-# ifdef _LIBC
-/* Make these definitions weak in libc, so POSIX programs can redefine
- these names if they don't use our functions, and still use
- regcomp/regexec above without link errors. */
-weak_function
-# endif
-re_comp (s)
- const char *s;
-{
- reg_errcode_t ret;
- char *fastmap;
-
- if (!s)
- {
- if (!re_comp_buf.buffer)
- return gettext ("No previous regular expression");
- return 0;
- }
-
- if (re_comp_buf.buffer)
- {
- fastmap = re_comp_buf.fastmap;
- re_comp_buf.fastmap = NULL;
- __regfree (&re_comp_buf);
- memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
- re_comp_buf.fastmap = fastmap;
- }
-
- if (re_comp_buf.fastmap == NULL)
- {
- re_comp_buf.fastmap = (char *) malloc (SBC_MAX);
- if (re_comp_buf.fastmap == NULL)
- return (char *) gettext (__re_error_msgid
- + __re_error_msgid_idx[(int) REG_ESPACE]);
- }
-
- /* Since `re_exec' always passes NULL for the `regs' argument, we
- don't need to initialize the pattern buffer fields which affect it. */
-
- /* Match anchors at newlines. */
- re_comp_buf.newline_anchor = 1;
-
- ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
-
- if (!ret)
- return NULL;
-
- /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
- return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
-}
-
-#ifdef _LIBC
-libc_freeres_fn (free_mem)
-{
- __regfree (&re_comp_buf);
-}
-#endif
-
-#endif /* _REGEX_RE_COMP */
-
-/* Internal entry point.
- Compile the regular expression PATTERN, whose length is LENGTH.
- SYNTAX indicate regular expression's syntax. */
-
-static reg_errcode_t
-re_compile_internal (preg, pattern, length, syntax)
- regex_t *preg;
- const char * pattern;
- int length;
- reg_syntax_t syntax;
-{
- reg_errcode_t err = REG_NOERROR;
- re_dfa_t *dfa;
- re_string_t regexp;
-
- /* Initialize the pattern buffer. */
- preg->fastmap_accurate = 0;
- preg->syntax = syntax;
- preg->not_bol = preg->not_eol = 0;
- preg->used = 0;
- preg->re_nsub = 0;
- preg->can_be_null = 0;
- preg->regs_allocated = REGS_UNALLOCATED;
-
- /* Initialize the dfa. */
- dfa = (re_dfa_t *) preg->buffer;
- if (BE (preg->allocated < sizeof (re_dfa_t), 0))
- {
- /* If zero allocated, but buffer is non-null, try to realloc
- enough space. This loses if buffer's address is bogus, but
- that is the user's responsibility. If ->buffer is NULL this
- is a simple allocation. */
- dfa = re_realloc (preg->buffer, re_dfa_t, 1);
- if (dfa == NULL)
- return REG_ESPACE;
- preg->allocated = sizeof (re_dfa_t);
- preg->buffer = (unsigned char *) dfa;
- }
- preg->used = sizeof (re_dfa_t);
-
- err = init_dfa (dfa, length);
- if (BE (err != REG_NOERROR, 0))
- {
- free_dfa_content (dfa);
- preg->buffer = NULL;
- preg->allocated = 0;
- return err;
- }
-#ifdef DEBUG
- dfa->re_str = re_malloc (char, length + 1);
- strncpy (dfa->re_str, pattern, length + 1);
-#endif
-
- err = re_string_construct (®exp, pattern, length, preg->translate,
- syntax & RE_ICASE, dfa);
- if (BE (err != REG_NOERROR, 0))
- {
- re_compile_internal_free_return:
- free_workarea_compile (preg);
- re_string_destruct (®exp);
- free_dfa_content (dfa);
- preg->buffer = NULL;
- preg->allocated = 0;
- return err;
- }
-
- /* Parse the regular expression, and build a structure tree. */
- preg->re_nsub = 0;
- dfa->str_tree = parse (®exp, preg, syntax, &err);
- if (BE (dfa->str_tree == NULL, 0))
- goto re_compile_internal_free_return;
-
-#ifdef RE_ENABLE_I18N
- /* If possible, do searching in single byte encoding to speed things up. */
- if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
- optimize_utf8 (dfa);
-#endif
-
- /* Analyze the tree and collect information which is necessary to
- create the dfa. */
- err = analyze (dfa);
- if (BE (err != REG_NOERROR, 0))
- goto re_compile_internal_free_return;
-
- /* Then create the initial state of the dfa. */
- err = create_initial_state (dfa);
-
- /* Release work areas. */
- free_workarea_compile (preg);
- re_string_destruct (®exp);
-
- if (BE (err != REG_NOERROR, 0))
- {
- free_dfa_content (dfa);
- preg->buffer = NULL;
- preg->allocated = 0;
- }
-
- return err;
-}
-
-/* Initialize DFA. We use the length of the regular expression PAT_LEN
- as the initial length of some arrays. */
-
-static reg_errcode_t
-init_dfa (dfa, pat_len)
- re_dfa_t *dfa;
- int pat_len;
-{
- int table_size;
-
- memset (dfa, '\0', sizeof (re_dfa_t));
-
- /* Force allocation of str_tree_storage the first time. */
- dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
-
- dfa->nodes_alloc = pat_len + 1;
- dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc);
-
- dfa->states_alloc = pat_len + 1;
-
- /* table_size = 2 ^ ceil(log pat_len) */
- for (table_size = 1; table_size > 0; table_size <<= 1)
- if (table_size > pat_len)
- break;
-
- dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
- dfa->state_hash_mask = table_size - 1;
-
- dfa->subexps_alloc = 1;
- dfa->subexps = re_malloc (re_subexp_t, dfa->subexps_alloc);
-
- dfa->mb_cur_max = MB_CUR_MAX;
-#ifdef _LIBC
- if (dfa->mb_cur_max == 6
- && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)
- dfa->is_utf8 = 1;
- dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
- != 0);
-#endif
-#ifdef RE_ENABLE_I18N
- if (dfa->mb_cur_max > 1)
- {
- int i, j, ch;
-
- dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset), 1);
- if (BE (dfa->sb_char == NULL, 0))
- return REG_ESPACE;
- if (dfa->is_utf8)
- memset (dfa->sb_char, 255, sizeof (unsigned int) * BITSET_UINTS / 2);
- else
- for (i = 0, ch = 0; i < BITSET_UINTS; ++i)
- for (j = 0; j < UINT_BITS; ++j, ++ch)
- if (btowc (ch) != WEOF)
- dfa->sb_char[i] |= 1 << j;
- }
-#endif
-
- if (BE (dfa->nodes == NULL || dfa->state_table == NULL
- || dfa->subexps == NULL, 0))
- return REG_ESPACE;
- return REG_NOERROR;
-}
-
-/* Initialize WORD_CHAR table, which indicate which character is
- "word". In this case "word" means that it is the word construction
- character used by some operators like "\<", "\>", etc. */
-
-static void
-init_word_char (dfa)
- re_dfa_t *dfa;
-{
- int i, j, ch;
- dfa->word_ops_used = 1;
- for (i = 0, ch = 0; i < BITSET_UINTS; ++i)
- for (j = 0; j < UINT_BITS; ++j, ++ch)
- if (isalnum (ch) || ch == '_')
- dfa->word_char[i] |= 1 << j;
-}
-
-/* Free the work area which are only used while compiling. */
-
-static void
-free_workarea_compile (preg)
- regex_t *preg;
-{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
- bin_tree_storage_t *storage, *next;
- for (storage = dfa->str_tree_storage; storage; storage = next)
- {
- next = storage->next;
- re_free (storage);
- }
- dfa->str_tree_storage = NULL;
- dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
- dfa->str_tree = NULL;
- re_free (dfa->org_indices);
- dfa->org_indices = NULL;
-}
-
-/* Create initial states for all contexts. */
-
-static reg_errcode_t
-create_initial_state (dfa)
- re_dfa_t *dfa;
-{
- int first, i;
- reg_errcode_t err;
- re_node_set init_nodes;
-
- /* Initial states have the epsilon closure of the node which is
- the first node of the regular expression. */
- first = dfa->str_tree->first;
- dfa->init_node = first;
- err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
- if (BE (err != REG_NOERROR, 0))
- return err;
-
- /* The back-references which are in initial states can epsilon transit,
- since in this case all of the subexpressions can be null.
- Then we add epsilon closures of the nodes which are the next nodes of
- the back-references. */
- if (dfa->nbackref > 0)
- for (i = 0; i < init_nodes.nelem; ++i)
- {
- int node_idx = init_nodes.elems[i];
- re_token_type_t type = dfa->nodes[node_idx].type;
-
- int clexp_idx;
- if (type != OP_BACK_REF)
- continue;
- for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx)
- {
- re_token_t *clexp_node;
- clexp_node = dfa->nodes + init_nodes.elems[clexp_idx];
- if (clexp_node->type == OP_CLOSE_SUBEXP
- && clexp_node->opr.idx + 1 == dfa->nodes[node_idx].opr.idx)
- break;
- }
- if (clexp_idx == init_nodes.nelem)
- continue;
-
- if (type == OP_BACK_REF)
- {
- int dest_idx = dfa->edests[node_idx].elems[0];
- if (!re_node_set_contains (&init_nodes, dest_idx))
- {
- re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx);
- i = 0;
- }
- }
- }
-
- /* It must be the first time to invoke acquire_state. */
- dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
- /* We don't check ERR here, since the initial state must not be NULL. */
- if (BE (dfa->init_state == NULL, 0))
- return err;
- if (dfa->init_state->has_constraint)
- {
- dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes,
- CONTEXT_WORD);
- dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes,
- CONTEXT_NEWLINE);
- dfa->init_state_begbuf = re_acquire_state_context (&err, dfa,
- &init_nodes,
- CONTEXT_NEWLINE
- | CONTEXT_BEGBUF);
- if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL
- || dfa->init_state_begbuf == NULL, 0))
- return err;
- }
- else
- dfa->init_state_word = dfa->init_state_nl
- = dfa->init_state_begbuf = dfa->init_state;
-
- re_node_set_free (&init_nodes);
- return REG_NOERROR;
-}
-
-#ifdef RE_ENABLE_I18N
-/* If it is possible to do searching in single byte encoding instead of UTF-8
- to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
- DFA nodes where needed. */
-
-static void
-optimize_utf8 (dfa)
- re_dfa_t *dfa;
-{
- int node, i, mb_chars = 0, has_period = 0;
-
- for (node = 0; node < dfa->nodes_len; ++node)
- switch (dfa->nodes[node].type)
- {
- case CHARACTER:
- if (dfa->nodes[node].opr.c >= 0x80)
- mb_chars = 1;
- break;
- case ANCHOR:
- switch (dfa->nodes[node].opr.idx)
- {
- case LINE_FIRST:
- case LINE_LAST:
- case BUF_FIRST:
- case BUF_LAST:
- break;
- default:
- /* Word anchors etc. cannot be handled. */
- return;
- }
- break;
- case OP_PERIOD:
- has_period = 1;
- break;
- case OP_BACK_REF:
- case OP_ALT:
- case END_OF_RE:
- case OP_DUP_ASTERISK:
- case OP_DUP_QUESTION:
- case OP_OPEN_SUBEXP:
- case OP_CLOSE_SUBEXP:
- break;
- case SIMPLE_BRACKET:
- /* Just double check. */
- for (i = 0x80 / UINT_BITS; i < BITSET_UINTS; ++i)
- if (dfa->nodes[node].opr.sbcset[i])
- return;
- break;
- default:
- return;
- }
-
- if (mb_chars || has_period)
- for (node = 0; node < dfa->nodes_len; ++node)
- {
- if (dfa->nodes[node].type == CHARACTER
- && dfa->nodes[node].opr.c >= 0x80)
- dfa->nodes[node].mb_partial = 0;
- else if (dfa->nodes[node].type == OP_PERIOD)
- dfa->nodes[node].type = OP_UTF8_PERIOD;
- }
-
- /* The search can be in single byte locale. */
- dfa->mb_cur_max = 1;
- dfa->is_utf8 = 0;
- dfa->has_mb_node = dfa->nbackref > 0 || has_period;
-}
-#endif
-
-/* Analyze the structure tree, and calculate "first", "next", "edest",
- "eclosure", and "inveclosure". */
-
-static reg_errcode_t
-analyze (dfa)
- re_dfa_t *dfa;
-{
- int i;
- reg_errcode_t ret;
-
- /* Allocate arrays. */
- dfa->nexts = re_malloc (int, dfa->nodes_alloc);
- dfa->org_indices = re_malloc (int, dfa->nodes_alloc);
- dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
- dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
- dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_alloc);
- if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL
- || dfa->eclosures == NULL || dfa->inveclosures == NULL, 0))
- return REG_ESPACE;
- /* Initialize them. */
- for (i = 0; i < dfa->nodes_len; ++i)
- {
- dfa->nexts[i] = -1;
- re_node_set_init_empty (dfa->edests + i);
- re_node_set_init_empty (dfa->eclosures + i);
- re_node_set_init_empty (dfa->inveclosures + i);
- }
-
- ret = analyze_tree (dfa, dfa->str_tree);
- if (BE (ret == REG_NOERROR, 1))
- {
- ret = calc_eclosure (dfa);
- if (ret == REG_NOERROR)
- calc_inveclosure (dfa);
- }
- return ret;
-}
-
-/* Helper functions for analyze.
- This function calculate "first", "next", and "edest" for the subtree
- whose root is NODE. */
-
-static reg_errcode_t
-analyze_tree (dfa, node)
- re_dfa_t *dfa;
- bin_tree_t *node;
-{
- reg_errcode_t ret;
- if (node->first == -1)
- calc_first (dfa, node);
- if (node->next == -1)
- calc_next (dfa, node);
- if (node->eclosure.nelem == 0)
- calc_epsdest (dfa, node);
- /* Calculate "first" etc. for the left child. */
- if (node->left != NULL)
- {
- ret = analyze_tree (dfa, node->left);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
- }
- /* Calculate "first" etc. for the right child. */
- if (node->right != NULL)
- {
- ret = analyze_tree (dfa, node->right);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
- }
- return REG_NOERROR;
-}
-
-/* Calculate "first" for the node NODE. */
-static void
-calc_first (dfa, node)
- re_dfa_t *dfa;
- bin_tree_t *node;
-{
- int idx, type;
- idx = node->node_idx;
- type = (node->type == 0) ? dfa->nodes[idx].type : node->type;
-
- switch (type)
- {
-#ifdef DEBUG
- case OP_OPEN_BRACKET:
- case OP_CLOSE_BRACKET:
- case OP_OPEN_DUP_NUM:
- case OP_CLOSE_DUP_NUM:
- case OP_DUP_PLUS:
- case OP_NON_MATCH_LIST:
- case OP_OPEN_COLL_ELEM:
- case OP_CLOSE_COLL_ELEM:
- case OP_OPEN_EQUIV_CLASS:
- case OP_CLOSE_EQUIV_CLASS:
- case OP_OPEN_CHAR_CLASS:
- case OP_CLOSE_CHAR_CLASS:
- /* These must not appear here. */
- assert (0);
-#endif
- case END_OF_RE:
- case CHARACTER:
- case OP_PERIOD:
- case OP_DUP_ASTERISK:
- case OP_DUP_QUESTION:
-#ifdef RE_ENABLE_I18N
- case OP_UTF8_PERIOD:
- case COMPLEX_BRACKET:
-#endif /* RE_ENABLE_I18N */
- case SIMPLE_BRACKET:
- case OP_BACK_REF:
- case ANCHOR:
- case OP_OPEN_SUBEXP:
- case OP_CLOSE_SUBEXP:
- node->first = idx;
- break;
- case OP_ALT:
- node->first = idx;
- break;
- /* else fall through */
- default:
-#ifdef DEBUG
- assert (node->left != NULL);
-#endif
- if (node->left->first == -1)
- calc_first (dfa, node->left);
- node->first = node->left->first;
- break;
- }
-}
-
-/* Calculate "next" for the node NODE. */
-
-static void
-calc_next (dfa, node)
- re_dfa_t *dfa;
- bin_tree_t *node;
-{
- int idx, type;
- bin_tree_t *parent = node->parent;
- if (parent == NULL)
- {
- node->next = -1;
- idx = node->node_idx;
- if (node->type == 0)
- dfa->nexts[idx] = node->next;
- return;
- }
-
- idx = parent->node_idx;
- type = (parent->type == 0) ? dfa->nodes[idx].type : parent->type;
-
- switch (type)
- {
- case OP_DUP_ASTERISK:
- node->next = idx;
- break;
- case CONCAT:
- if (parent->left == node)
- {
- if (parent->right->first == -1)
- calc_first (dfa, parent->right);
- node->next = parent->right->first;
- break;
- }
- /* else fall through */
- default:
- if (parent->next == -1)
- calc_next (dfa, parent);
- node->next = parent->next;
- break;
- }
- idx = node->node_idx;
- if (node->type == 0)
- dfa->nexts[idx] = node->next;
-}
-
-/* Calculate "edest" for the node NODE. */
-
-static void
-calc_epsdest (dfa, node)
- re_dfa_t *dfa;
- bin_tree_t *node;
-{
- int idx;
- idx = node->node_idx;
- if (node->type == 0)
- {
- if (dfa->nodes[idx].type == OP_DUP_ASTERISK
- || dfa->nodes[idx].type == OP_DUP_QUESTION)
- {
- if (node->left->first == -1)
- calc_first (dfa, node->left);
- if (node->next == -1)
- calc_next (dfa, node);
- re_node_set_init_2 (dfa->edests + idx, node->left->first,
- node->next);
- }
- else if (dfa->nodes[idx].type == OP_ALT)
- {
- int left, right;
- if (node->left != NULL)
- {
- if (node->left->first == -1)
- calc_first (dfa, node->left);
- left = node->left->first;
- }
- else
- {
- if (node->next == -1)
- calc_next (dfa, node);
- left = node->next;
- }
- if (node->right != NULL)
- {
- if (node->right->first == -1)
- calc_first (dfa, node->right);
- right = node->right->first;
- }
- else
- {
- if (node->next == -1)
- calc_next (dfa, node);
- right = node->next;
- }
- re_node_set_init_2 (dfa->edests + idx, left, right);
- }
- else if (dfa->nodes[idx].type == ANCHOR
- || dfa->nodes[idx].type == OP_OPEN_SUBEXP
- || dfa->nodes[idx].type == OP_CLOSE_SUBEXP
- || dfa->nodes[idx].type == OP_BACK_REF)
- re_node_set_init_1 (dfa->edests + idx, node->next);
- else
- assert (!IS_EPSILON_NODE (dfa->nodes[idx].type));
- }
-}
-
-/* Duplicate the epsilon closure of the node ROOT_NODE.
- Note that duplicated nodes have constraint INIT_CONSTRAINT in addition
- to their own constraint. */
-
-static reg_errcode_t
-duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node,
- init_constraint)
- re_dfa_t *dfa;
- int top_org_node, top_clone_node, root_node;
- unsigned int init_constraint;
-{
- reg_errcode_t err;
- int org_node, clone_node, ret;
- unsigned int constraint = init_constraint;
- for (org_node = top_org_node, clone_node = top_clone_node;;)
- {
- int org_dest, clone_dest;
- if (dfa->nodes[org_node].type == OP_BACK_REF)
- {
- /* If the back reference epsilon-transit, its destination must
- also have the constraint. Then duplicate the epsilon closure
- of the destination of the back reference, and store it in
- edests of the back reference. */
- org_dest = dfa->nexts[org_node];
- re_node_set_empty (dfa->edests + clone_node);
- err = duplicate_node (&clone_dest, dfa, org_dest, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
- dfa->nexts[clone_node] = dfa->nexts[org_node];
- ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (ret < 0, 0))
- return REG_ESPACE;
- }
- else if (dfa->edests[org_node].nelem == 0)
- {
- /* In case of the node can't epsilon-transit, don't duplicate the
- destination and store the original destination as the
- destination of the node. */
- dfa->nexts[clone_node] = dfa->nexts[org_node];
- break;
- }
- else if (dfa->edests[org_node].nelem == 1)
- {
- /* In case of the node can epsilon-transit, and it has only one
- destination. */
- org_dest = dfa->edests[org_node].elems[0];
- re_node_set_empty (dfa->edests + clone_node);
- if (dfa->nodes[org_node].type == ANCHOR)
- {
- /* In case of the node has another constraint, append it. */
- if (org_node == root_node && clone_node != org_node)
- {
- /* ...but if the node is root_node itself, it means the
- epsilon closure have a loop, then tie it to the
- destination of the root_node. */
- ret = re_node_set_insert (dfa->edests + clone_node,
- org_dest);
- if (BE (ret < 0, 0))
- return REG_ESPACE;
- break;
- }
- constraint |= dfa->nodes[org_node].opr.ctx_type;
- }
- err = duplicate_node (&clone_dest, dfa, org_dest, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
- ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (ret < 0, 0))
- return REG_ESPACE;
- }
- else /* dfa->edests[org_node].nelem == 2 */
- {
- /* In case of the node can epsilon-transit, and it has two
- destinations. E.g. '|', '*', '+', '?'. */
- org_dest = dfa->edests[org_node].elems[0];
- re_node_set_empty (dfa->edests + clone_node);
- /* Search for a duplicated node which satisfies the constraint. */
- clone_dest = search_duplicated_node (dfa, org_dest, constraint);
- if (clone_dest == -1)
- {
- /* There are no such a duplicated node, create a new one. */
- err = duplicate_node (&clone_dest, dfa, org_dest, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
- ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (ret < 0, 0))
- return REG_ESPACE;
- err = duplicate_node_closure (dfa, org_dest, clone_dest,
- root_node, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- else
- {
- /* There are a duplicated node which satisfy the constraint,
- use it to avoid infinite loop. */
- ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (ret < 0, 0))
- return REG_ESPACE;
- }
-
- org_dest = dfa->edests[org_node].elems[1];
- err = duplicate_node (&clone_dest, dfa, org_dest, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
- ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (ret < 0, 0))
- return REG_ESPACE;
- }
- org_node = org_dest;
- clone_node = clone_dest;
- }
- return REG_NOERROR;
-}
-
-/* Search for a node which is duplicated from the node ORG_NODE, and
- satisfies the constraint CONSTRAINT. */
-
-static int
-search_duplicated_node (dfa, org_node, constraint)
- re_dfa_t *dfa;
- int org_node;
- unsigned int constraint;
-{
- int idx;
- for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx)
- {
- if (org_node == dfa->org_indices[idx]
- && constraint == dfa->nodes[idx].constraint)
- return idx; /* Found. */
- }
- return -1; /* Not found. */
-}
-
-/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT.
- The new index will be stored in NEW_IDX and return REG_NOERROR if succeeded,
- otherwise return the error code. */
-
-static reg_errcode_t
-duplicate_node (new_idx, dfa, org_idx, constraint)
- re_dfa_t *dfa;
- int *new_idx, org_idx;
- unsigned int constraint;
-{
- int dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx], 1);
- if (BE (dup_idx == -1, 0))
- return REG_ESPACE;
- dfa->nodes[dup_idx].constraint = constraint;
- if (dfa->nodes[org_idx].type == ANCHOR)
- dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type;
- dfa->nodes[dup_idx].duplicated = 1;
- re_node_set_init_empty (dfa->edests + dup_idx);
- re_node_set_init_empty (dfa->eclosures + dup_idx);
- re_node_set_init_empty (dfa->inveclosures + dup_idx);
-
- /* Store the index of the original node. */
- dfa->org_indices[dup_idx] = org_idx;
- *new_idx = dup_idx;
- return REG_NOERROR;
-}
-
-static void
-calc_inveclosure (dfa)
- re_dfa_t *dfa;
-{
- int src, idx, dest;
- for (src = 0; src < dfa->nodes_len; ++src)
- {
- for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
- {
- dest = dfa->eclosures[src].elems[idx];
- re_node_set_insert (dfa->inveclosures + dest, src);
- }
- }
-}
-
-/* Calculate "eclosure" for all the node in DFA. */
-
-static reg_errcode_t
-calc_eclosure (dfa)
- re_dfa_t *dfa;
-{
- int node_idx, incomplete;
-#ifdef DEBUG
- assert (dfa->nodes_len > 0);
-#endif
- incomplete = 0;
- /* For each nodes, calculate epsilon closure. */
- for (node_idx = 0; ; ++node_idx)
- {
- reg_errcode_t err;
- re_node_set eclosure_elem;
- if (node_idx == dfa->nodes_len)
- {
- if (!incomplete)
- break;
- incomplete = 0;
- node_idx = 0;
- }
-
-#ifdef DEBUG
- assert (dfa->eclosures[node_idx].nelem != -1);
-#endif
- /* If we have already calculated, skip it. */
- if (dfa->eclosures[node_idx].nelem != 0)
- continue;
- /* Calculate epsilon closure of `node_idx'. */
- err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, 1);
- if (BE (err != REG_NOERROR, 0))
- return err;
-
- if (dfa->eclosures[node_idx].nelem == 0)
- {
- incomplete = 1;
- re_node_set_free (&eclosure_elem);
- }
- }
- return REG_NOERROR;
-}
-
-/* Calculate epsilon closure of NODE. */
-
-static reg_errcode_t
-calc_eclosure_iter (new_set, dfa, node, root)
- re_node_set *new_set;
- re_dfa_t *dfa;
- int node, root;
-{
- reg_errcode_t err;
- unsigned int constraint;
- int i, incomplete;
- re_node_set eclosure;
- incomplete = 0;
- err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
- if (BE (err != REG_NOERROR, 0))
- return err;
-
- /* This indicates that we are calculating this node now.
- We reference this value to avoid infinite loop. */
- dfa->eclosures[node].nelem = -1;
-
- constraint = ((dfa->nodes[node].type == ANCHOR)
- ? dfa->nodes[node].opr.ctx_type : 0);
- /* If the current node has constraints, duplicate all nodes.
- Since they must inherit the constraints. */
- if (constraint && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
- {
- int org_node, cur_node;
- org_node = cur_node = node;
- err = duplicate_node_closure (dfa, node, node, node, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
-
- /* Expand each epsilon destination nodes. */
- if (IS_EPSILON_NODE(dfa->nodes[node].type))
- for (i = 0; i < dfa->edests[node].nelem; ++i)
- {
- re_node_set eclosure_elem;
- int edest = dfa->edests[node].elems[i];
- /* If calculating the epsilon closure of `edest' is in progress,
- return intermediate result. */
- if (dfa->eclosures[edest].nelem == -1)
- {
- incomplete = 1;
- continue;
- }
- /* If we haven't calculated the epsilon closure of `edest' yet,
- calculate now. Otherwise use calculated epsilon closure. */
- if (dfa->eclosures[edest].nelem == 0)
- {
- err = calc_eclosure_iter (&eclosure_elem, dfa, edest, 0);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- else
- eclosure_elem = dfa->eclosures[edest];
- /* Merge the epsilon closure of `edest'. */
- re_node_set_merge (&eclosure, &eclosure_elem);
- /* If the epsilon closure of `edest' is incomplete,
- the epsilon closure of this node is also incomplete. */
- if (dfa->eclosures[edest].nelem == 0)
- {
- incomplete = 1;
- re_node_set_free (&eclosure_elem);
- }
- }
-
- /* Epsilon closures include itself. */
- re_node_set_insert (&eclosure, node);
- if (incomplete && !root)
- dfa->eclosures[node].nelem = 0;
- else
- dfa->eclosures[node] = eclosure;
- *new_set = eclosure;
- return REG_NOERROR;
-}
-
-/* Functions for token which are used in the parser. */
-
-/* Fetch a token from INPUT.
- We must not use this function inside bracket expressions. */
-
-static void
-fetch_token (result, input, syntax)
- re_token_t *result;
- re_string_t *input;
- reg_syntax_t syntax;
-{
- re_string_skip_bytes (input, peek_token (result, input, syntax));
-}
-
-/* Peek a token from INPUT, and return the length of the token.
- We must not use this function inside bracket expressions. */
-
-static int
-peek_token (token, input, syntax)
- re_token_t *token;
- re_string_t *input;
- reg_syntax_t syntax;
-{
- unsigned char c;
-
- if (re_string_eoi (input))
- {
- token->type = END_OF_RE;
- return 0;
- }
-
- c = re_string_peek_byte (input, 0);
- token->opr.c = c;
-
- token->word_char = 0;
-#ifdef RE_ENABLE_I18N
- token->mb_partial = 0;
- if (input->mb_cur_max > 1 &&
- !re_string_first_byte (input, re_string_cur_idx (input)))
- {
- token->type = CHARACTER;
- token->mb_partial = 1;
- return 1;
- }
-#endif
- if (c == '\\')
- {
- unsigned char c2;
- if (re_string_cur_idx (input) + 1 >= re_string_length (input))
- {
- token->type = BACK_SLASH;
- return 1;
- }
-
- c2 = re_string_peek_byte_case (input, 1);
- token->opr.c = c2;
- token->type = CHARACTER;
-#ifdef RE_ENABLE_I18N
- if (input->mb_cur_max > 1)
- {
- wint_t wc = re_string_wchar_at (input,
- re_string_cur_idx (input) + 1);
- token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
- }
- else
-#endif
- token->word_char = IS_WORD_CHAR (c2) != 0;
-
- switch (c2)
- {
- case '|':
- if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR))
- token->type = OP_ALT;
- break;
- case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- if (!(syntax & RE_NO_BK_REFS))
- {
- token->type = OP_BACK_REF;
- token->opr.idx = c2 - '0';
- }
- break;
- case '<':
- if (!(syntax & RE_NO_GNU_OPS))
- {
- token->type = ANCHOR;
- token->opr.ctx_type = WORD_FIRST;
- }
- break;
- case '>':
- if (!(syntax & RE_NO_GNU_OPS))
- {
- token->type = ANCHOR;
- token->opr.ctx_type = WORD_LAST;
- }
- break;
- case 'b':
- if (!(syntax & RE_NO_GNU_OPS))
- {
- token->type = ANCHOR;
- token->opr.ctx_type = WORD_DELIM;
- }
- break;
- case 'B':
- if (!(syntax & RE_NO_GNU_OPS))
- {
- token->type = ANCHOR;
- token->opr.ctx_type = INSIDE_WORD;
- }
- break;
- case 'w':
- if (!(syntax & RE_NO_GNU_OPS))
- token->type = OP_WORD;
- break;
- case 'W':
- if (!(syntax & RE_NO_GNU_OPS))
- token->type = OP_NOTWORD;
- break;
- case 's':
- if (!(syntax & RE_NO_GNU_OPS))
- token->type = OP_SPACE;
- break;
- case 'S':
- if (!(syntax & RE_NO_GNU_OPS))
- token->type = OP_NOTSPACE;
- break;
- case '`':
- if (!(syntax & RE_NO_GNU_OPS))
- {
- token->type = ANCHOR;
- token->opr.ctx_type = BUF_FIRST;
- }
- break;
- case '\'':
- if (!(syntax & RE_NO_GNU_OPS))
- {
- token->type = ANCHOR;
- token->opr.ctx_type = BUF_LAST;
- }
- break;
- case '(':
- if (!(syntax & RE_NO_BK_PARENS))
- token->type = OP_OPEN_SUBEXP;
- break;
- case ')':
- if (!(syntax & RE_NO_BK_PARENS))
- token->type = OP_CLOSE_SUBEXP;
- break;
- case '+':
- if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
- token->type = OP_DUP_PLUS;
- break;
- case '?':
- if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
- token->type = OP_DUP_QUESTION;
- break;
- case '{':
- if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
- token->type = OP_OPEN_DUP_NUM;
- break;
- case '}':
- if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
- token->type = OP_CLOSE_DUP_NUM;
- break;
- default:
- break;
- }
- return 2;
- }
-
- token->type = CHARACTER;
-#ifdef RE_ENABLE_I18N
- if (input->mb_cur_max > 1)
- {
- wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
- token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
- }
- else
-#endif
- token->word_char = IS_WORD_CHAR (token->opr.c);
-
- switch (c)
- {
- case '\n':
- if (syntax & RE_NEWLINE_ALT)
- token->type = OP_ALT;
- break;
- case '|':
- if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR))
- token->type = OP_ALT;
- break;
- case '*':
- token->type = OP_DUP_ASTERISK;
- break;
- case '+':
- if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
- token->type = OP_DUP_PLUS;
- break;
- case '?':
- if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
- token->type = OP_DUP_QUESTION;
- break;
- case '{':
- if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
- token->type = OP_OPEN_DUP_NUM;
- break;
- case '}':
- if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
- token->type = OP_CLOSE_DUP_NUM;
- break;
- case '(':
- if (syntax & RE_NO_BK_PARENS)
- token->type = OP_OPEN_SUBEXP;
- break;
- case ')':
- if (syntax & RE_NO_BK_PARENS)
- token->type = OP_CLOSE_SUBEXP;
- break;
- case '[':
- token->type = OP_OPEN_BRACKET;
- break;
- case '.':
- token->type = OP_PERIOD;
- break;
- case '^':
- if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) &&
- re_string_cur_idx (input) != 0)
- {
- char prev = re_string_peek_byte (input, -1);
- if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
- break;
- }
- token->type = ANCHOR;
- token->opr.ctx_type = LINE_FIRST;
- break;
- case '$':
- if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) &&
- re_string_cur_idx (input) + 1 != re_string_length (input))
- {
- re_token_t next;
- re_string_skip_bytes (input, 1);
- peek_token (&next, input, syntax);
- re_string_skip_bytes (input, -1);
- if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP)
- break;
- }
- token->type = ANCHOR;
- token->opr.ctx_type = LINE_LAST;
- break;
- default:
- break;
- }
- return 1;
-}
-
-/* Peek a token from INPUT, and return the length of the token.
- We must not use this function out of bracket expressions. */
-
-static int
-peek_token_bracket (token, input, syntax)
- re_token_t *token;
- re_string_t *input;
- reg_syntax_t syntax;
-{
- unsigned char c;
- if (re_string_eoi (input))
- {
- token->type = END_OF_RE;
- return 0;
- }
- c = re_string_peek_byte (input, 0);
- token->opr.c = c;
-
-#ifdef RE_ENABLE_I18N
- if (input->mb_cur_max > 1 &&
- !re_string_first_byte (input, re_string_cur_idx (input)))
- {
- token->type = CHARACTER;
- return 1;
- }
-#endif /* RE_ENABLE_I18N */
-
- if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
- && re_string_cur_idx (input) + 1 < re_string_length (input))
- {
- /* In this case, '\' escape a character. */
- unsigned char c2;
- re_string_skip_bytes (input, 1);
- c2 = re_string_peek_byte (input, 0);
- token->opr.c = c2;
- token->type = CHARACTER;
- return 1;
- }
- if (c == '[') /* '[' is a special char in a bracket exps. */
- {
- unsigned char c2;
- int token_len;
- if (re_string_cur_idx (input) + 1 < re_string_length (input))
- c2 = re_string_peek_byte (input, 1);
- else
- c2 = 0;
- token->opr.c = c2;
- token_len = 2;
- switch (c2)
- {
- case '.':
- token->type = OP_OPEN_COLL_ELEM;
- break;
- case '=':
- token->type = OP_OPEN_EQUIV_CLASS;
- break;
- case ':':
- if (syntax & RE_CHAR_CLASSES)
- {
- token->type = OP_OPEN_CHAR_CLASS;
- break;
- }
- /* else fall through. */
- default:
- token->type = CHARACTER;
- token->opr.c = c;
- token_len = 1;
- break;
- }
- return token_len;
- }
- switch (c)
- {
- case '-':
- token->type = OP_CHARSET_RANGE;
- break;
- case ']':
- token->type = OP_CLOSE_BRACKET;
- break;
- case '^':
- token->type = OP_NON_MATCH_LIST;
- break;
- default:
- token->type = CHARACTER;
- }
- return 1;
-}
-
-/* Functions for parser. */
-
-/* Entry point of the parser.
- Parse the regular expression REGEXP and return the structure tree.
- If an error is occured, ERR is set by error code, and return NULL.
- This function build the following tree, from regular expression :
- CAT
- / \
- / \
- EOR
-
- CAT means concatenation.
- EOR means end of regular expression. */
-
-static bin_tree_t *
-parse (regexp, preg, syntax, err)
- re_string_t *regexp;
- regex_t *preg;
- reg_syntax_t syntax;
- reg_errcode_t *err;
-{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
- bin_tree_t *tree, *eor, *root;
- re_token_t current_token;
- dfa->syntax = syntax;
- fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
- tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- eor = re_dfa_add_tree_node (dfa, NULL, NULL, ¤t_token);
- if (tree != NULL)
- root = create_tree (dfa, tree, eor, CONCAT, 0);
- else
- root = eor;
- if (BE (eor == NULL || root == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- return root;
-}
-
-/* This function build the following tree, from regular expression
- |:
- ALT
- / \
- / \
-
-
- ALT means alternative, which represents the operator `|'. */
-
-static bin_tree_t *
-parse_reg_exp (regexp, preg, token, syntax, nest, err)
- re_string_t *regexp;
- regex_t *preg;
- re_token_t *token;
- reg_syntax_t syntax;
- int nest;
- reg_errcode_t *err;
-{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
- bin_tree_t *tree, *branch = NULL;
- tree = parse_branch (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
-
- while (token->type == OP_ALT)
- {
- re_token_t alt_token = *token;
- fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
- if (token->type != OP_ALT && token->type != END_OF_RE
- && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
- {
- branch = parse_branch (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && branch == NULL, 0))
- return NULL;
- }
- else
- branch = NULL;
- tree = re_dfa_add_tree_node (dfa, tree, branch, &alt_token);
- if (BE (tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- dfa->has_plural_match = 1;
- }
- return tree;
-}
-
-/* This function build the following tree, from regular expression
- :
- CAT
- / \
- / \
-
-
- CAT means concatenation. */
-
-static bin_tree_t *
-parse_branch (regexp, preg, token, syntax, nest, err)
- re_string_t *regexp;
- regex_t *preg;
- re_token_t *token;
- reg_syntax_t syntax;
- int nest;
- reg_errcode_t *err;
-{
- bin_tree_t *tree, *exp;
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
- tree = parse_expression (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
-
- while (token->type != OP_ALT && token->type != END_OF_RE
- && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
- {
- exp = parse_expression (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && exp == NULL, 0))
- {
- return NULL;
- }
- if (tree != NULL && exp != NULL)
- {
- tree = create_tree (dfa, tree, exp, CONCAT, 0);
- if (tree == NULL)
- {
- *err = REG_ESPACE;
- return NULL;
- }
- }
- else if (tree == NULL)
- tree = exp;
- /* Otherwise exp == NULL, we don't need to create new tree. */
- }
- return tree;
-}
-
-/* This function build the following tree, from regular expression a*:
- *
- |
- a
-*/
-
-static bin_tree_t *
-parse_expression (regexp, preg, token, syntax, nest, err)
- re_string_t *regexp;
- regex_t *preg;
- re_token_t *token;
- reg_syntax_t syntax;
- int nest;
- reg_errcode_t *err;
-{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
- bin_tree_t *tree;
- switch (token->type)
- {
- case CHARACTER:
- tree = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
-#ifdef RE_ENABLE_I18N
- if (dfa->mb_cur_max > 1)
- {
- while (!re_string_eoi (regexp)
- && !re_string_first_byte (regexp, re_string_cur_idx (regexp)))
- {
- bin_tree_t *mbc_remain;
- fetch_token (token, regexp, syntax);
- mbc_remain = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- tree = create_tree (dfa, tree, mbc_remain, CONCAT, 0);
- if (BE (mbc_remain == NULL || tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- }
- }
-#endif
- break;
- case OP_OPEN_SUBEXP:
- tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- break;
- case OP_OPEN_BRACKET:
- tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- break;
- case OP_BACK_REF:
- if (BE (preg->re_nsub < token->opr.idx
- || dfa->subexps[token->opr.idx - 1].end == -1, 0))
- {
- *err = REG_ESUBREG;
- return NULL;
- }
- dfa->used_bkref_map |= 1 << (token->opr.idx - 1);
- tree = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- ++dfa->nbackref;
- dfa->has_mb_node = 1;
- break;
- case OP_OPEN_DUP_NUM:
- if (syntax & RE_CONTEXT_INVALID_DUP)
- {
- *err = REG_BADRPT;
- return NULL;
- }
- /* FALLTHROUGH */
- case OP_DUP_ASTERISK:
- case OP_DUP_PLUS:
- case OP_DUP_QUESTION:
- if (syntax & RE_CONTEXT_INVALID_OPS)
- {
- *err = REG_BADRPT;
- return NULL;
- }
- else if (syntax & RE_CONTEXT_INDEP_OPS)
- {
- fetch_token (token, regexp, syntax);
- return parse_expression (regexp, preg, token, syntax, nest, err);
- }
- /* else fall through */
- case OP_CLOSE_SUBEXP:
- if ((token->type == OP_CLOSE_SUBEXP) &&
- !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
- {
- *err = REG_ERPAREN;
- return NULL;
- }
- /* else fall through */
- case OP_CLOSE_DUP_NUM:
- /* We treat it as a normal character. */
-
- /* Then we can these characters as normal characters. */
- token->type = CHARACTER;
- /* mb_partial and word_char bits should be initialized already
- by peek_token. */
- tree = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- break;
- case ANCHOR:
- if ((token->opr.ctx_type
- & (WORD_DELIM | INSIDE_WORD | WORD_FIRST | WORD_LAST))
- && dfa->word_ops_used == 0)
- init_word_char (dfa);
- if (token->opr.ctx_type == WORD_DELIM)
- {
- bin_tree_t *tree_first, *tree_last;
- token->opr.ctx_type = WORD_FIRST;
- tree_first = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- token->opr.ctx_type = WORD_LAST;
- tree_last = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- token->type = OP_ALT;
- tree = re_dfa_add_tree_node (dfa, tree_first, tree_last, token);
- if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- }
- else
- {
- tree = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- }
- /* We must return here, since ANCHORs can't be followed
- by repetition operators.
- eg. RE"^*" is invalid or "",
- it must not be "". */
- fetch_token (token, regexp, syntax);
- return tree;
- case OP_PERIOD:
- tree = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- if (dfa->mb_cur_max > 1)
- dfa->has_mb_node = 1;
- break;
- case OP_WORD:
- tree = build_charclass_op (dfa, regexp->trans, "alnum", "_", 0, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- break;
- case OP_NOTWORD:
- tree = build_charclass_op (dfa, regexp->trans, "alnum", "_", 1, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- break;
- case OP_SPACE:
- tree = build_charclass_op (dfa, regexp->trans, "space", "", 0, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- break;
- case OP_NOTSPACE:
- tree = build_charclass_op (dfa, regexp->trans, "space", "", 1, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- break;
- case OP_ALT:
- case END_OF_RE:
- return NULL;
- case BACK_SLASH:
- *err = REG_EESCAPE;
- return NULL;
- default:
- /* Must not happen? */
-#ifdef DEBUG
- assert (0);
-#endif
- return NULL;
- }
- fetch_token (token, regexp, syntax);
-
- while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
- || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
- {
- tree = parse_dup_op (tree, regexp, dfa, token, syntax, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- /* In BRE consecutive duplications are not allowed. */
- if ((syntax & RE_CONTEXT_INVALID_DUP)
- && (token->type == OP_DUP_ASTERISK
- || token->type == OP_OPEN_DUP_NUM))
- {
- *err = REG_BADRPT;
- return NULL;
- }
- dfa->has_plural_match = 1;
- }
-
- return tree;
-}
-
-/* This function build the following tree, from regular expression
- ():
- SUBEXP
- |
-
-*/
-
-static bin_tree_t *
-parse_sub_exp (regexp, preg, token, syntax, nest, err)
- re_string_t *regexp;
- regex_t *preg;
- re_token_t *token;
- reg_syntax_t syntax;
- int nest;
- reg_errcode_t *err;
-{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
- bin_tree_t *tree, *left_par, *right_par;
- size_t cur_nsub;
- cur_nsub = preg->re_nsub++;
- if (BE (dfa->subexps_alloc < preg->re_nsub, 0))
- {
- re_subexp_t *new_array;
- dfa->subexps_alloc *= 2;
- new_array = re_realloc (dfa->subexps, re_subexp_t, dfa->subexps_alloc);
- if (BE (new_array == NULL, 0))
- {
- dfa->subexps_alloc /= 2;
- *err = REG_ESPACE;
- return NULL;
- }
- dfa->subexps = new_array;
- }
- dfa->subexps[cur_nsub].start = dfa->nodes_len;
- dfa->subexps[cur_nsub].end = -1;
-
- left_par = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- if (BE (left_par == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- dfa->nodes[left_par->node_idx].opr.idx = cur_nsub;
- fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
-
- /* The subexpression may be a null string. */
- if (token->type == OP_CLOSE_SUBEXP)
- tree = NULL;
- else
- {
- tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
- return NULL;
- }
- if (BE (token->type != OP_CLOSE_SUBEXP, 0))
- {
- *err = REG_EPAREN;
- return NULL;
- }
- right_par = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- dfa->subexps[cur_nsub].end = dfa->nodes_len;
- tree = ((tree == NULL) ? right_par
- : create_tree (dfa, tree, right_par, CONCAT, 0));
- tree = create_tree (dfa, left_par, tree, CONCAT, 0);
- if (BE (right_par == NULL || tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- dfa->nodes[right_par->node_idx].opr.idx = cur_nsub;
-
- return tree;
-}
-
-/* This function parse repetition operators like "*", "+", "{1,3}" etc. */
-
-static bin_tree_t *
-parse_dup_op (elem, regexp, dfa, token, syntax, err)
- bin_tree_t *elem;
- re_string_t *regexp;
- re_dfa_t *dfa;
- re_token_t *token;
- reg_syntax_t syntax;
- reg_errcode_t *err;
-{
- re_token_t dup_token;
- bin_tree_t *tree = NULL;
- int i, start, end, start_idx = re_string_cur_idx (regexp);
- re_token_t start_token = *token;
-
- if (token->type == OP_OPEN_DUP_NUM)
- {
- end = 0;
- start = fetch_number (regexp, token, syntax);
- if (start == -1)
- {
- if (token->type == CHARACTER && token->opr.c == ',')
- start = 0; /* We treat "{,m}" as "{0,m}". */
- else
- {
- *err = REG_BADBR; /* {} is invalid. */
- return NULL;
- }
- }
- if (BE (start != -2, 1))
- {
- /* We treat "{n}" as "{n,n}". */
- end = ((token->type == OP_CLOSE_DUP_NUM) ? start
- : ((token->type == CHARACTER && token->opr.c == ',')
- ? fetch_number (regexp, token, syntax) : -2));
- }
- if (BE (start == -2 || end == -2, 0))
- {
- /* Invalid sequence. */
- if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0))
- {
- if (token->type == END_OF_RE)
- *err = REG_EBRACE;
- else
- *err = REG_BADBR;
-
- return NULL;
- }
-
- /* If the syntax bit is set, rollback. */
- re_string_set_index (regexp, start_idx);
- *token = start_token;
- token->type = CHARACTER;
- /* mb_partial and word_char bits should be already initialized by
- peek_token. */
- return elem;
- }
-
- if (BE (end != -1 && start > end, 0))
- {
- /* First number greater than second. */
- *err = REG_BADBR;
- return NULL;
- }
- }
- else
- {
- start = (token->type == OP_DUP_PLUS) ? 1 : 0;
- end = (token->type == OP_DUP_QUESTION) ? 1 : -1;
- }
-
- /* Treat "{0}*" etc. as "{0}". */
- if (BE (elem == NULL, 0))
- start = end = 0;
-
- /* Extract "{n,m}" to "...{0,}". */
- else if (BE (start > 0, 0))
- {
- tree = elem;
- for (i = 2; i <= start; ++i)
- {
- elem = duplicate_tree (elem, dfa);
- tree = create_tree (dfa, tree, elem, CONCAT, 0);
- if (BE (elem == NULL || tree == NULL, 0))
- goto parse_dup_op_espace;
- }
- }
-
- if (BE (end != start, 1))
- {
- dup_token.type = (end == -1 ? OP_DUP_ASTERISK : OP_DUP_QUESTION);
- if (BE (start > 0, 0))
- {
- elem = duplicate_tree (elem, dfa);
- if (BE (elem == NULL, 0))
- goto parse_dup_op_espace;
-
- /* This subexpression will be marked as optional, so that
- empty matches do not touch the registers. */
- mark_opt_subexp (elem, dfa);
-
- /* Prepare the tree with the modifier. */
- elem = re_dfa_add_tree_node (dfa, elem, NULL, &dup_token);
- tree = create_tree (dfa, tree, elem, CONCAT, 0);
- }
- else
- {
- /* We do not need to duplicate the tree because we have not
- created it yet. */
- mark_opt_subexp (elem, dfa);
- tree = elem = re_dfa_add_tree_node (dfa, elem, NULL, &dup_token);
- }
-
- if (BE (elem == NULL || tree == NULL, 0))
- goto parse_dup_op_espace;
-
- /* This loop is actually executed only when end != -1,
- to rewrite {0,n} as ???... We have
- already created the start+1-th copy. */
- for (i = start + 2; i <= end; ++i)
- {
- elem = duplicate_tree (elem, dfa);
- tree = create_tree (dfa, tree, elem, CONCAT, 0);
- if (BE (elem == NULL || tree == NULL, 0))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- }
- }
-
- fetch_token (token, regexp, syntax);
- return tree;
-
- parse_dup_op_espace:
- *err = REG_ESPACE;
- return NULL;
-}
-
-/* Size of the names for collating symbol/equivalence_class/character_class.
- I'm not sure, but maybe enough. */
-#define BRACKET_NAME_BUF_SIZE 32
-
-#ifndef _LIBC
- /* Local function for parse_bracket_exp only used in case of NOT _LIBC.
- Build the range expression which starts from START_ELEM, and ends
- at END_ELEM. The result are written to MBCSET and SBCSET.
- RANGE_ALLOC is the allocated size of mbcset->range_starts, and
- mbcset->range_ends, is a pointer argument sinse we may
- update it. */
-
-static reg_errcode_t
-# ifdef RE_ENABLE_I18N
-build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
- re_charset_t *mbcset;
- int *range_alloc;
-# else /* not RE_ENABLE_I18N */
-build_range_exp (sbcset, start_elem, end_elem)
-# endif /* not RE_ENABLE_I18N */
- re_bitset_ptr_t sbcset;
- bracket_elem_t *start_elem, *end_elem;
-{
- unsigned int start_ch, end_ch;
- /* Equivalence Classes and Character Classes can't be a range start/end. */
- if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
- || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
- 0))
- return REG_ERANGE;
-
- /* We can handle no multi character collating elements without libc
- support. */
- if (BE ((start_elem->type == COLL_SYM
- && strlen ((char *) start_elem->opr.name) > 1)
- || (end_elem->type == COLL_SYM
- && strlen ((char *) end_elem->opr.name) > 1), 0))
- return REG_ECOLLATE;
-
-# ifdef RE_ENABLE_I18N
- {
- wchar_t wc, start_wc, end_wc;
- wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
-
- start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
- : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
- : 0));
- end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
- : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
- : 0));
- start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
- ? __btowc (start_ch) : start_elem->opr.wch);
- end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
- ? __btowc (end_ch) : end_elem->opr.wch);
- if (start_wc == WEOF || end_wc == WEOF)
- return REG_ECOLLATE;
- cmp_buf[0] = start_wc;
- cmp_buf[4] = end_wc;
- if (wcscoll (cmp_buf, cmp_buf + 4) > 0)
- return REG_ERANGE;
-
- /* Got valid collation sequence values, add them as a new entry.
- However, for !_LIBC we have no collation elements: if the
- character set is single byte, the single byte character set
- that we build below suffices. parse_bracket_exp passes
- no MBCSET if dfa->mb_cur_max == 1. */
- if (mbcset)
- {
- /* Check the space of the arrays. */
- if (BE (*range_alloc == mbcset->nranges, 0))
- {
- /* There is not enough space, need realloc. */
- wchar_t *new_array_start, *new_array_end;
- int new_nranges;
-
- /* +1 in case of mbcset->nranges is 0. */
- new_nranges = 2 * mbcset->nranges + 1;
- /* Use realloc since mbcset->range_starts and mbcset->range_ends
- are NULL if *range_alloc == 0. */
- new_array_start = re_realloc (mbcset->range_starts, wchar_t,
- new_nranges);
- new_array_end = re_realloc (mbcset->range_ends, wchar_t,
- new_nranges);
-
- if (BE (new_array_start == NULL || new_array_end == NULL, 0))
- return REG_ESPACE;
-
- mbcset->range_starts = new_array_start;
- mbcset->range_ends = new_array_end;
- *range_alloc = new_nranges;
- }
-
- mbcset->range_starts[mbcset->nranges] = start_wc;
- mbcset->range_ends[mbcset->nranges++] = end_wc;
- }
-
- /* Build the table for single byte characters. */
- for (wc = 0; wc < SBC_MAX; ++wc)
- {
- cmp_buf[2] = wc;
- if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
- && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
- bitset_set (sbcset, wc);
- }
- }
-# else /* not RE_ENABLE_I18N */
- {
- unsigned int ch;
- start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
- : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
- : 0));
- end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
- : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
- : 0));
- if (start_ch > end_ch)
- return REG_ERANGE;
- /* Build the table for single byte characters. */
- for (ch = 0; ch < SBC_MAX; ++ch)
- if (start_ch <= ch && ch <= end_ch)
- bitset_set (sbcset, ch);
- }
-# endif /* not RE_ENABLE_I18N */
- return REG_NOERROR;
-}
-#endif /* not _LIBC */
-
-#ifndef _LIBC
-/* Helper function for parse_bracket_exp only used in case of NOT _LIBC..
- Build the collating element which is represented by NAME.
- The result are written to MBCSET and SBCSET.
- COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
- pointer argument since we may update it. */
-
-static reg_errcode_t
-# ifdef RE_ENABLE_I18N
-build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
- re_charset_t *mbcset;
- int *coll_sym_alloc;
-# else /* not RE_ENABLE_I18N */
-build_collating_symbol (sbcset, name)
-# endif /* not RE_ENABLE_I18N */
- re_bitset_ptr_t sbcset;
- const unsigned char *name;
-{
- size_t name_len = strlen ((const char *) name);
- if (BE (name_len != 1, 0))
- return REG_ECOLLATE;
- else
- {
- bitset_set (sbcset, name[0]);
- return REG_NOERROR;
- }
-}
-#endif /* not _LIBC */
-
-/* This function parse bracket expression like "[abc]", "[a-c]",
- "[[.a-a.]]" etc. */
-
-static bin_tree_t *
-parse_bracket_exp (regexp, dfa, token, syntax, err)
- re_string_t *regexp;
- re_dfa_t *dfa;
- re_token_t *token;
- reg_syntax_t syntax;
- reg_errcode_t *err;
-{
-#ifdef _LIBC
- const unsigned char *collseqmb;
- const char *collseqwc;
- uint32_t nrules;
- int32_t table_size;
- const int32_t *symb_table;
- const unsigned char *extra;
-
- /* Local function for parse_bracket_exp used in _LIBC environement.
- Seek the collating symbol entry correspondings to NAME.
- Return the index of the symbol in the SYMB_TABLE. */
-
- static inline int32_t
- __attribute ((always_inline))
- seek_collating_symbol_entry (name, name_len)
- const unsigned char *name;
- size_t name_len;
- {
- int32_t hash = elem_hash ((const char *) name, name_len);
- int32_t elem = hash % table_size;
- int32_t second = hash % (table_size - 2);
- while (symb_table[2 * elem] != 0)
- {
- /* First compare the hashing value. */
- if (symb_table[2 * elem] == hash
- /* Compare the length of the name. */
- && name_len == extra[symb_table[2 * elem + 1]]
- /* Compare the name. */
- && memcmp (name, &extra[symb_table[2 * elem + 1] + 1],
- name_len) == 0)
- {
- /* Yep, this is the entry. */
- break;
- }
-
- /* Next entry. */
- elem += second;
- }
- return elem;
- }
-
- /* Local function for parse_bracket_exp used in _LIBC environement.
- Look up the collation sequence value of BR_ELEM.
- Return the value if succeeded, UINT_MAX otherwise. */
-
- static inline unsigned int
- __attribute ((always_inline))
- lookup_collation_sequence_value (br_elem)
- bracket_elem_t *br_elem;
- {
- if (br_elem->type == SB_CHAR)
- {
- /*
- if (MB_CUR_MAX == 1)
- */
- if (nrules == 0)
- return collseqmb[br_elem->opr.ch];
- else
- {
- wint_t wc = __btowc (br_elem->opr.ch);
- return __collseq_table_lookup (collseqwc, wc);
- }
- }
- else if (br_elem->type == MB_CHAR)
- {
- return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
- }
- else if (br_elem->type == COLL_SYM)
- {
- size_t sym_name_len = strlen ((char *) br_elem->opr.name);
- if (nrules != 0)
- {
- int32_t elem, idx;
- elem = seek_collating_symbol_entry (br_elem->opr.name,
- sym_name_len);
- if (symb_table[2 * elem] != 0)
- {
- /* We found the entry. */
- idx = symb_table[2 * elem + 1];
- /* Skip the name of collating element name. */
- idx += 1 + extra[idx];
- /* Skip the byte sequence of the collating element. */
- idx += 1 + extra[idx];
- /* Adjust for the alignment. */
- idx = (idx + 3) & ~3;
- /* Skip the multibyte collation sequence value. */
- idx += sizeof (unsigned int);
- /* Skip the wide char sequence of the collating element. */
- idx += sizeof (unsigned int) *
- (1 + *(unsigned int *) (extra + idx));
- /* Return the collation sequence value. */
- return *(unsigned int *) (extra + idx);
- }
- else if (symb_table[2 * elem] == 0 && sym_name_len == 1)
- {
- /* No valid character. Match it as a single byte
- character. */
- return collseqmb[br_elem->opr.name[0]];
- }
- }
- else if (sym_name_len == 1)
- return collseqmb[br_elem->opr.name[0]];
- }
- return UINT_MAX;
- }
-
- /* Local function for parse_bracket_exp used in _LIBC environement.
- Build the range expression which starts from START_ELEM, and ends
- at END_ELEM. The result are written to MBCSET and SBCSET.
- RANGE_ALLOC is the allocated size of mbcset->range_starts, and
- mbcset->range_ends, is a pointer argument sinse we may
- update it. */
-
- static inline reg_errcode_t
- __attribute ((always_inline))
- build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
- re_charset_t *mbcset;
- int *range_alloc;
- re_bitset_ptr_t sbcset;
- bracket_elem_t *start_elem, *end_elem;
- {
- unsigned int ch;
- uint32_t start_collseq;
- uint32_t end_collseq;
-
- /* Equivalence Classes and Character Classes can't be a range
- start/end. */
- if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
- || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
- 0))
- return REG_ERANGE;
-
- start_collseq = lookup_collation_sequence_value (start_elem);
- end_collseq = lookup_collation_sequence_value (end_elem);
- /* Check start/end collation sequence values. */
- if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0))
- return REG_ECOLLATE;
- if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
- return REG_ERANGE;
-
- /* Got valid collation sequence values, add them as a new entry.
- However, if we have no collation elements, and the character set
- is single byte, the single byte character set that we
- build below suffices. */
- if (nrules > 0 || dfa->mb_cur_max > 1)
- {
- /* Check the space of the arrays. */
- if (BE (*range_alloc == mbcset->nranges, 0))
- {
- /* There is not enough space, need realloc. */
- uint32_t *new_array_start;
- uint32_t *new_array_end;
- int new_nranges;
-
- /* +1 in case of mbcset->nranges is 0. */
- new_nranges = 2 * mbcset->nranges + 1;
- new_array_start = re_realloc (mbcset->range_starts, uint32_t,
- new_nranges);
- new_array_end = re_realloc (mbcset->range_ends, uint32_t,
- new_nranges);
-
- if (BE (new_array_start == NULL || new_array_end == NULL, 0))
- return REG_ESPACE;
-
- mbcset->range_starts = new_array_start;
- mbcset->range_ends = new_array_end;
- *range_alloc = new_nranges;
- }
-
- mbcset->range_starts[mbcset->nranges] = start_collseq;
- mbcset->range_ends[mbcset->nranges++] = end_collseq;
- }
-
- /* Build the table for single byte characters. */
- for (ch = 0; ch < SBC_MAX; ch++)
- {
- uint32_t ch_collseq;
- /*
- if (MB_CUR_MAX == 1)
- */
- if (nrules == 0)
- ch_collseq = collseqmb[ch];
- else
- ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
- if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
- bitset_set (sbcset, ch);
- }
- return REG_NOERROR;
- }
-
- /* Local function for parse_bracket_exp used in _LIBC environement.
- Build the collating element which is represented by NAME.
- The result are written to MBCSET and SBCSET.
- COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
- pointer argument sinse we may update it. */
-
- static inline reg_errcode_t
- __attribute ((always_inline))
- build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
- re_charset_t *mbcset;
- int *coll_sym_alloc;
- re_bitset_ptr_t sbcset;
- const unsigned char *name;
- {
- int32_t elem, idx;
- size_t name_len = strlen ((const char *) name);
- if (nrules != 0)
- {
- elem = seek_collating_symbol_entry (name, name_len);
- if (symb_table[2 * elem] != 0)
- {
- /* We found the entry. */
- idx = symb_table[2 * elem + 1];
- /* Skip the name of collating element name. */
- idx += 1 + extra[idx];
- }
- else if (symb_table[2 * elem] == 0 && name_len == 1)
- {
- /* No valid character, treat it as a normal
- character. */
- bitset_set (sbcset, name[0]);
- return REG_NOERROR;
- }
- else
- return REG_ECOLLATE;
-
- /* Got valid collation sequence, add it as a new entry. */
- /* Check the space of the arrays. */
- if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0))
- {
- /* Not enough, realloc it. */
- /* +1 in case of mbcset->ncoll_syms is 0. */
- int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
- /* Use realloc since mbcset->coll_syms is NULL
- if *alloc == 0. */
- int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
- new_coll_sym_alloc);
- if (BE (new_coll_syms == NULL, 0))
- return REG_ESPACE;
- mbcset->coll_syms = new_coll_syms;
- *coll_sym_alloc = new_coll_sym_alloc;
- }
- mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
- return REG_NOERROR;
- }
- else
- {
- if (BE (name_len != 1, 0))
- return REG_ECOLLATE;
- else
- {
- bitset_set (sbcset, name[0]);
- return REG_NOERROR;
- }
- }
- }
-#endif
-
- re_token_t br_token;
- re_bitset_ptr_t sbcset;
-#ifdef RE_ENABLE_I18N
- re_charset_t *mbcset;
- int coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
- int equiv_class_alloc = 0, char_class_alloc = 0;
-#endif /* not RE_ENABLE_I18N */
- int non_match = 0;
- bin_tree_t *work_tree;
- int token_len;
- int first_round = 1;
-#ifdef _LIBC
- collseqmb = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
- nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
- if (nrules)
- {
- /*
- if (MB_CUR_MAX > 1)
- */
- collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
- table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
- symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE,
- _NL_COLLATE_SYMB_TABLEMB);
- extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
- _NL_COLLATE_SYMB_EXTRAMB);
- }
-#endif
- sbcset = (re_bitset_ptr_t) calloc (sizeof (unsigned int), BITSET_UINTS);
-#ifdef RE_ENABLE_I18N
- mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
-#endif /* RE_ENABLE_I18N */
-#ifdef RE_ENABLE_I18N
- if (BE (sbcset == NULL || mbcset == NULL, 0))
-#else
- if (BE (sbcset == NULL, 0))
-#endif /* RE_ENABLE_I18N */
- {
- *err = REG_ESPACE;
- return NULL;
- }
-
- token_len = peek_token_bracket (token, regexp, syntax);
- if (BE (token->type == END_OF_RE, 0))
- {
- *err = REG_BADPAT;
- goto parse_bracket_exp_free_return;
- }
- if (token->type == OP_NON_MATCH_LIST)
- {
-#ifdef RE_ENABLE_I18N
- mbcset->non_match = 1;
-#endif /* not RE_ENABLE_I18N */
- non_match = 1;
- if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
- bitset_set (sbcset, '\0');
- re_string_skip_bytes (regexp, token_len); /* Skip a token. */
- token_len = peek_token_bracket (token, regexp, syntax);
- if (BE (token->type == END_OF_RE, 0))
- {
- *err = REG_BADPAT;
- goto parse_bracket_exp_free_return;
- }
- }
-
- /* We treat the first ']' as a normal character. */
- if (token->type == OP_CLOSE_BRACKET)
- token->type = CHARACTER;
-
- while (1)
- {
- bracket_elem_t start_elem, end_elem;
- unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE];
- unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE];
- reg_errcode_t ret;
- int token_len2 = 0, is_range_exp = 0;
- re_token_t token2;
-
- start_elem.opr.name = start_name_buf;
- ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
- syntax, first_round);
- if (BE (ret != REG_NOERROR, 0))
- {
- *err = ret;
- goto parse_bracket_exp_free_return;
- }
- first_round = 0;
-
- /* Get information about the next token. We need it in any case. */
- token_len = peek_token_bracket (token, regexp, syntax);
-
- /* Do not check for ranges if we know they are not allowed. */
- if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
- {
- if (BE (token->type == END_OF_RE, 0))
- {
- *err = REG_EBRACK;
- goto parse_bracket_exp_free_return;
- }
- if (token->type == OP_CHARSET_RANGE)
- {
- re_string_skip_bytes (regexp, token_len); /* Skip '-'. */
- token_len2 = peek_token_bracket (&token2, regexp, syntax);
- if (BE (token2.type == END_OF_RE, 0))
- {
- *err = REG_EBRACK;
- goto parse_bracket_exp_free_return;
- }
- if (token2.type == OP_CLOSE_BRACKET)
- {
- /* We treat the last '-' as a normal character. */
- re_string_skip_bytes (regexp, -token_len);
- token->type = CHARACTER;
- }
- else
- is_range_exp = 1;
- }
- }
-
- if (is_range_exp == 1)
- {
- end_elem.opr.name = end_name_buf;
- ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
- dfa, syntax, 1);
- if (BE (ret != REG_NOERROR, 0))
- {
- *err = ret;
- goto parse_bracket_exp_free_return;
- }
-
- token_len = peek_token_bracket (token, regexp, syntax);
-
-#ifdef _LIBC
- *err = build_range_exp (sbcset, mbcset, &range_alloc,
- &start_elem, &end_elem);
-#else
-# ifdef RE_ENABLE_I18N
- *err = build_range_exp (sbcset,
- dfa->mb_cur_max > 1 ? mbcset : NULL,
- &range_alloc, &start_elem, &end_elem);
-# else
- *err = build_range_exp (sbcset, &start_elem, &end_elem);
-# endif
-#endif /* RE_ENABLE_I18N */
- if (BE (*err != REG_NOERROR, 0))
- goto parse_bracket_exp_free_return;
- }
- else
- {
- switch (start_elem.type)
- {
- case SB_CHAR:
- bitset_set (sbcset, start_elem.opr.ch);
- break;
-#ifdef RE_ENABLE_I18N
- case MB_CHAR:
- /* Check whether the array has enough space. */
- if (BE (mbchar_alloc == mbcset->nmbchars, 0))
- {
- wchar_t *new_mbchars;
- /* Not enough, realloc it. */
- /* +1 in case of mbcset->nmbchars is 0. */
- mbchar_alloc = 2 * mbcset->nmbchars + 1;
- /* Use realloc since array is NULL if *alloc == 0. */
- new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
- mbchar_alloc);
- if (BE (new_mbchars == NULL, 0))
- goto parse_bracket_exp_espace;
- mbcset->mbchars = new_mbchars;
- }
- mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
- break;
-#endif /* RE_ENABLE_I18N */
- case EQUIV_CLASS:
- *err = build_equiv_class (sbcset,
-#ifdef RE_ENABLE_I18N
- mbcset, &equiv_class_alloc,
-#endif /* RE_ENABLE_I18N */
- start_elem.opr.name);
- if (BE (*err != REG_NOERROR, 0))
- goto parse_bracket_exp_free_return;
- break;
- case COLL_SYM:
- *err = build_collating_symbol (sbcset,
-#ifdef RE_ENABLE_I18N
- mbcset, &coll_sym_alloc,
-#endif /* RE_ENABLE_I18N */
- start_elem.opr.name);
- if (BE (*err != REG_NOERROR, 0))
- goto parse_bracket_exp_free_return;
- break;
- case CHAR_CLASS:
- *err = build_charclass (regexp->trans, sbcset,
-#ifdef RE_ENABLE_I18N
- mbcset, &char_class_alloc,
-#endif /* RE_ENABLE_I18N */
- start_elem.opr.name, syntax);
- if (BE (*err != REG_NOERROR, 0))
- goto parse_bracket_exp_free_return;
- break;
- default:
- assert (0);
- break;
- }
- }
- if (BE (token->type == END_OF_RE, 0))
- {
- *err = REG_EBRACK;
- goto parse_bracket_exp_free_return;
- }
- if (token->type == OP_CLOSE_BRACKET)
- break;
- }
-
- re_string_skip_bytes (regexp, token_len); /* Skip a token. */
-
- /* If it is non-matching list. */
- if (non_match)
- bitset_not (sbcset);
-
-#ifdef RE_ENABLE_I18N
- /* Ensure only single byte characters are set. */
- if (dfa->mb_cur_max > 1)
- bitset_mask (sbcset, dfa->sb_char);
-#endif /* RE_ENABLE_I18N */
-
- /* Build a tree for simple bracket. */
- br_token.type = SIMPLE_BRACKET;
- br_token.opr.sbcset = sbcset;
- work_tree = re_dfa_add_tree_node (dfa, NULL, NULL, &br_token);
- if (BE (work_tree == NULL, 0))
- goto parse_bracket_exp_espace;
-
-#ifdef RE_ENABLE_I18N
- if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes
- || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes
- || mbcset->non_match)))
- {
- re_token_t alt_token;
- bin_tree_t *mbc_tree;
- int sbc_idx;
- /* Build a tree for complex bracket. */
- dfa->has_mb_node = 1;
- for (sbc_idx = 0; sbc_idx < BITSET_UINTS; ++sbc_idx)
- if (sbcset[sbc_idx])
- break;
- /* If there are no bits set in sbcset, there is no point
- of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */
- if (sbc_idx == BITSET_UINTS)
- {
- re_free (sbcset);
- dfa->nodes[work_tree->node_idx].type = COMPLEX_BRACKET;
- dfa->nodes[work_tree->node_idx].opr.mbcset = mbcset;
- return work_tree;
- }
- br_token.type = COMPLEX_BRACKET;
- br_token.opr.mbcset = mbcset;
- mbc_tree = re_dfa_add_tree_node (dfa, NULL, NULL, &br_token);
- if (BE (mbc_tree == NULL, 0))
- goto parse_bracket_exp_espace;
- /* Then join them by ALT node. */
- alt_token.type = OP_ALT;
- dfa->has_plural_match = 1;
- work_tree = re_dfa_add_tree_node (dfa, work_tree, mbc_tree, &alt_token);
- if (BE (mbc_tree != NULL, 1))
- return work_tree;
- }
- else
- {
- free_charset (mbcset);
- return work_tree;
- }
-#else /* not RE_ENABLE_I18N */
- return work_tree;
-#endif /* not RE_ENABLE_I18N */
-
- parse_bracket_exp_espace:
- *err = REG_ESPACE;
- parse_bracket_exp_free_return:
- re_free (sbcset);
-#ifdef RE_ENABLE_I18N
- free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
- return NULL;
-}
-
-/* Parse an element in the bracket expression. */
-
-static reg_errcode_t
-parse_bracket_element (elem, regexp, token, token_len, dfa, syntax,
- accept_hyphen)
- bracket_elem_t *elem;
- re_string_t *regexp;
- re_token_t *token;
- int token_len;
- re_dfa_t *dfa;
- reg_syntax_t syntax;
- int accept_hyphen;
-{
-#ifdef RE_ENABLE_I18N
- int cur_char_size;
- cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
- if (cur_char_size > 1)
- {
- elem->type = MB_CHAR;
- elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp));
- re_string_skip_bytes (regexp, cur_char_size);
- return REG_NOERROR;
- }
-#endif /* RE_ENABLE_I18N */
- re_string_skip_bytes (regexp, token_len); /* Skip a token. */
- if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
- || token->type == OP_OPEN_EQUIV_CLASS)
- return parse_bracket_symbol (elem, regexp, token);
- if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen)
- {
- /* A '-' must only appear as anything but a range indicator before
- the closing bracket. Everything else is an error. */
- re_token_t token2;
- (void) peek_token_bracket (&token2, regexp, syntax);
- if (token2.type != OP_CLOSE_BRACKET)
- /* The actual error value is not standardized since this whole
- case is undefined. But ERANGE makes good sense. */
- return REG_ERANGE;
- }
- elem->type = SB_CHAR;
- elem->opr.ch = token->opr.c;
- return REG_NOERROR;
-}
-
-/* Parse a bracket symbol in the bracket expression. Bracket symbols are
- such as [::], [..], and
- [==]. */
-
-static reg_errcode_t
-parse_bracket_symbol (elem, regexp, token)
- bracket_elem_t *elem;
- re_string_t *regexp;
- re_token_t *token;
-{
- unsigned char ch, delim = token->opr.c;
- int i = 0;
- if (re_string_eoi(regexp))
- return REG_EBRACK;
- for (;; ++i)
- {
- if (i >= BRACKET_NAME_BUF_SIZE)
- return REG_EBRACK;
- if (token->type == OP_OPEN_CHAR_CLASS)
- ch = re_string_fetch_byte_case (regexp);
- else
- ch = re_string_fetch_byte (regexp);
- if (re_string_eoi(regexp))
- return REG_EBRACK;
- if (ch == delim && re_string_peek_byte (regexp, 0) == ']')
- break;
- elem->opr.name[i] = ch;
- }
- re_string_skip_bytes (regexp, 1);
- elem->opr.name[i] = '\0';
- switch (token->type)
- {
- case OP_OPEN_COLL_ELEM:
- elem->type = COLL_SYM;
- break;
- case OP_OPEN_EQUIV_CLASS:
- elem->type = EQUIV_CLASS;
- break;
- case OP_OPEN_CHAR_CLASS:
- elem->type = CHAR_CLASS;
- break;
- default:
- break;
- }
- return REG_NOERROR;
-}
-
- /* Helper function for parse_bracket_exp.
- Build the equivalence class which is represented by NAME.
- The result are written to MBCSET and SBCSET.
- EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes,
- is a pointer argument sinse we may update it. */
-
-static reg_errcode_t
-#ifdef RE_ENABLE_I18N
-build_equiv_class (sbcset, mbcset, equiv_class_alloc, name)
- re_charset_t *mbcset;
- int *equiv_class_alloc;
-#else /* not RE_ENABLE_I18N */
-build_equiv_class (sbcset, name)
-#endif /* not RE_ENABLE_I18N */
- re_bitset_ptr_t sbcset;
- const unsigned char *name;
-{
-#if defined _LIBC
- uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
- if (nrules != 0)
- {
- const int32_t *table, *indirect;
- const unsigned char *weights, *extra, *cp;
- unsigned char char_buf[2];
- int32_t idx1, idx2;
- unsigned int ch;
- size_t len;
- /* This #include defines a local function! */
-# include
- /* Calculate the index for equivalence class. */
- cp = name;
- table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
- weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
- _NL_COLLATE_WEIGHTMB);
- extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
- _NL_COLLATE_EXTRAMB);
- indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
- _NL_COLLATE_INDIRECTMB);
- idx1 = findidx (&cp);
- if (BE (idx1 == 0 || cp < name + strlen ((const char *) name), 0))
- /* This isn't a valid character. */
- return REG_ECOLLATE;
-
- /* Build single byte matcing table for this equivalence class. */
- char_buf[1] = (unsigned char) '\0';
- len = weights[idx1];
- for (ch = 0; ch < SBC_MAX; ++ch)
- {
- char_buf[0] = ch;
- cp = char_buf;
- idx2 = findidx (&cp);
-/*
- idx2 = table[ch];
-*/
- if (idx2 == 0)
- /* This isn't a valid character. */
- continue;
- if (len == weights[idx2])
- {
- int cnt = 0;
- while (cnt <= len &&
- weights[idx1 + 1 + cnt] == weights[idx2 + 1 + cnt])
- ++cnt;
-
- if (cnt > len)
- bitset_set (sbcset, ch);
- }
- }
- /* Check whether the array has enough space. */
- if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0))
- {
- /* Not enough, realloc it. */
- /* +1 in case of mbcset->nequiv_classes is 0. */
- int new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1;
- /* Use realloc since the array is NULL if *alloc == 0. */
- int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
- int32_t,
- new_equiv_class_alloc);
- if (BE (new_equiv_classes == NULL, 0))
- return REG_ESPACE;
- mbcset->equiv_classes = new_equiv_classes;
- *equiv_class_alloc = new_equiv_class_alloc;
- }
- mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1;
- }
- else
-#endif /* _LIBC */
- {
- if (BE (strlen ((const char *) name) != 1, 0))
- return REG_ECOLLATE;
- bitset_set (sbcset, *name);
- }
- return REG_NOERROR;
-}
-
- /* Helper function for parse_bracket_exp.
- Build the character class which is represented by NAME.
- The result are written to MBCSET and SBCSET.
- CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes,
- is a pointer argument sinse we may update it. */
-
-static reg_errcode_t
-#ifdef RE_ENABLE_I18N
-build_charclass (trans, sbcset, mbcset, char_class_alloc, class_name, syntax)
- re_charset_t *mbcset;
- int *char_class_alloc;
-#else /* not RE_ENABLE_I18N */
-build_charclass (trans, sbcset, class_name, syntax)
-#endif /* not RE_ENABLE_I18N */
- unsigned RE_TRANSLATE_TYPE trans;
- re_bitset_ptr_t sbcset;
- const unsigned char *class_name;
- reg_syntax_t syntax;
-{
- int i;
- const char *name = (const char *) class_name;
-
- /* In case of REG_ICASE "upper" and "lower" match the both of
- upper and lower cases. */
- if ((syntax & RE_ICASE)
- && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
- name = "alpha";
-
-#ifdef RE_ENABLE_I18N
- /* Check the space of the arrays. */
- if (BE (*char_class_alloc == mbcset->nchar_classes, 0))
- {
- /* Not enough, realloc it. */
- /* +1 in case of mbcset->nchar_classes is 0. */
- int new_char_class_alloc = 2 * mbcset->nchar_classes + 1;
- /* Use realloc since array is NULL if *alloc == 0. */
- wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
- new_char_class_alloc);
- if (BE (new_char_classes == NULL, 0))
- return REG_ESPACE;
- mbcset->char_classes = new_char_classes;
- *char_class_alloc = new_char_class_alloc;
- }
- mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
-#endif /* RE_ENABLE_I18N */
-
-#define BUILD_CHARCLASS_LOOP(ctype_func) \
- for (i = 0; i < SBC_MAX; ++i) \
- { \
- if (ctype_func (i)) \
- { \
- int ch = trans ? trans[i] : i; \
- bitset_set (sbcset, ch); \
- } \
- }
-
- if (strcmp (name, "alnum") == 0)
- BUILD_CHARCLASS_LOOP (isalnum)
- else if (strcmp (name, "cntrl") == 0)
- BUILD_CHARCLASS_LOOP (iscntrl)
- else if (strcmp (name, "lower") == 0)
- BUILD_CHARCLASS_LOOP (islower)
- else if (strcmp (name, "space") == 0)
- BUILD_CHARCLASS_LOOP (isspace)
- else if (strcmp (name, "alpha") == 0)
- BUILD_CHARCLASS_LOOP (isalpha)
- else if (strcmp (name, "digit") == 0)
- BUILD_CHARCLASS_LOOP (isdigit)
- else if (strcmp (name, "print") == 0)
- BUILD_CHARCLASS_LOOP (isprint)
- else if (strcmp (name, "upper") == 0)
- BUILD_CHARCLASS_LOOP (isupper)
- else if (strcmp (name, "blank") == 0)
- BUILD_CHARCLASS_LOOP (isblank)
- else if (strcmp (name, "graph") == 0)
- BUILD_CHARCLASS_LOOP (isgraph)
- else if (strcmp (name, "punct") == 0)
- BUILD_CHARCLASS_LOOP (ispunct)
- else if (strcmp (name, "xdigit") == 0)
- BUILD_CHARCLASS_LOOP (isxdigit)
- else
- return REG_ECTYPE;
-
- return REG_NOERROR;
-}
-
-static bin_tree_t *
-build_charclass_op (dfa, trans, class_name, extra, non_match, err)
- re_dfa_t *dfa;
- unsigned RE_TRANSLATE_TYPE trans;
- const unsigned char *class_name;
- const unsigned char *extra;
- int non_match;
- reg_errcode_t *err;
-{
- re_bitset_ptr_t sbcset;
-#ifdef RE_ENABLE_I18N
- re_charset_t *mbcset;
- int alloc = 0;
-#endif /* not RE_ENABLE_I18N */
- reg_errcode_t ret;
- re_token_t br_token;
- bin_tree_t *tree;
-
- sbcset = (re_bitset_ptr_t) calloc (sizeof (unsigned int), BITSET_UINTS);
-#ifdef RE_ENABLE_I18N
- mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
-#endif /* RE_ENABLE_I18N */
-
-#ifdef RE_ENABLE_I18N
- if (BE (sbcset == NULL || mbcset == NULL, 0))
-#else /* not RE_ENABLE_I18N */
- if (BE (sbcset == NULL, 0))
-#endif /* not RE_ENABLE_I18N */
- {
- *err = REG_ESPACE;
- return NULL;
- }
-
- if (non_match)
- {
-#ifdef RE_ENABLE_I18N
- /*
- if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
- bitset_set(cset->sbcset, '\0');
- */
- mbcset->non_match = 1;
-#endif /* not RE_ENABLE_I18N */
- }
-
- /* We don't care the syntax in this case. */
- ret = build_charclass (trans, sbcset,
-#ifdef RE_ENABLE_I18N
- mbcset, &alloc,
-#endif /* RE_ENABLE_I18N */
- class_name, 0);
-
- if (BE (ret != REG_NOERROR, 0))
- {
- re_free (sbcset);
-#ifdef RE_ENABLE_I18N
- free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
- *err = ret;
- return NULL;
- }
- /* \w match '_' also. */
- for (; *extra; extra++)
- bitset_set (sbcset, *extra);
-
- /* If it is non-matching list. */
- if (non_match)
- bitset_not (sbcset);
-
-#ifdef RE_ENABLE_I18N
- /* Ensure only single byte characters are set. */
- if (dfa->mb_cur_max > 1)
- bitset_mask (sbcset, dfa->sb_char);
-#endif
-
- /* Build a tree for simple bracket. */
- br_token.type = SIMPLE_BRACKET;
- br_token.opr.sbcset = sbcset;
- tree = re_dfa_add_tree_node (dfa, NULL, NULL, &br_token);
- if (BE (tree == NULL, 0))
- goto build_word_op_espace;
-
-#ifdef RE_ENABLE_I18N
- if (dfa->mb_cur_max > 1)
- {
- re_token_t alt_token;
- bin_tree_t *mbc_tree;
- /* Build a tree for complex bracket. */
- br_token.type = COMPLEX_BRACKET;
- br_token.opr.mbcset = mbcset;
- dfa->has_mb_node = 1;
- mbc_tree = re_dfa_add_tree_node (dfa, NULL, NULL, &br_token);
- if (BE (mbc_tree == NULL, 0))
- goto build_word_op_espace;
- /* Then join them by ALT node. */
- alt_token.type = OP_ALT;
- dfa->has_plural_match = 1;
- tree = re_dfa_add_tree_node (dfa, tree, mbc_tree, &alt_token);
- if (BE (mbc_tree != NULL, 1))
- return tree;
- }
- else
- {
- free_charset (mbcset);
- return tree;
- }
-#else /* not RE_ENABLE_I18N */
- return tree;
-#endif /* not RE_ENABLE_I18N */
-
- build_word_op_espace:
- re_free (sbcset);
-#ifdef RE_ENABLE_I18N
- free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
- *err = REG_ESPACE;
- return NULL;
-}
-
-/* This is intended for the expressions like "a{1,3}".
- Fetch a number from `input', and return the number.
- Return -1, if the number field is empty like "{,1}".
- Return -2, If an error is occured. */
-
-static int
-fetch_number (input, token, syntax)
- re_string_t *input;
- re_token_t *token;
- reg_syntax_t syntax;
-{
- int num = -1;
- unsigned char c;
- while (1)
- {
- fetch_token (token, input, syntax);
- c = token->opr.c;
- if (BE (token->type == END_OF_RE, 0))
- return -2;
- if (token->type == OP_CLOSE_DUP_NUM || c == ',')
- break;
- num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
- ? -2 : ((num == -1) ? c - '0' : num * 10 + c - '0'));
- num = (num > RE_DUP_MAX) ? -2 : num;
- }
- return num;
-}
-
-#ifdef RE_ENABLE_I18N
-static void
-free_charset (re_charset_t *cset)
-{
- re_free (cset->mbchars);
-# ifdef _LIBC
- re_free (cset->coll_syms);
- re_free (cset->equiv_classes);
- re_free (cset->range_starts);
- re_free (cset->range_ends);
-# endif
- re_free (cset->char_classes);
- re_free (cset);
-}
-#endif /* RE_ENABLE_I18N */
-
-/* Functions for binary tree operation. */
-
-/* Create a tree node. */
-
-static bin_tree_t *
-create_tree (dfa, left, right, type, index)
- re_dfa_t *dfa;
- bin_tree_t *left;
- bin_tree_t *right;
- re_token_type_t type;
- int index;
-{
- bin_tree_t *tree;
- if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0))
- {
- bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
-
- if (storage == NULL)
- return NULL;
- storage->next = dfa->str_tree_storage;
- dfa->str_tree_storage = storage;
- dfa->str_tree_storage_idx = 0;
- }
- tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++];
-
- tree->parent = NULL;
- tree->left = left;
- tree->right = right;
- tree->type = type;
- tree->node_idx = index;
- tree->first = -1;
- tree->next = -1;
- re_node_set_init_empty (&tree->eclosure);
-
- if (left != NULL)
- left->parent = tree;
- if (right != NULL)
- right->parent = tree;
- return tree;
-}
-
-/* Create both a DFA node and a tree for it. */
-
-static bin_tree_t *
-re_dfa_add_tree_node (dfa, left, right, token)
- re_dfa_t *dfa;
- bin_tree_t *left;
- bin_tree_t *right;
- const re_token_t *token;
-{
- int new_idx = re_dfa_add_node (dfa, *token, 0);
-
- if (new_idx == -1)
- return NULL;
-
- return create_tree (dfa, left, right, 0, new_idx);
-}
-
-/* Mark the tree SRC as an optional subexpression. */
-
-static void
-mark_opt_subexp (src, dfa)
- const bin_tree_t *src;
- re_dfa_t *dfa;
-{
- /* Pass an OPT_SUBEXP_IDX which is != 1 if the duplicated tree is
- a subexpression. */
- if (src->type == CONCAT
- && src->left->type == NON_TYPE
- && dfa->nodes[src->left->node_idx].type == OP_OPEN_SUBEXP)
- mark_opt_subexp_iter (src, dfa, dfa->nodes[src->left->node_idx].opr.idx);
-}
-
-
-/* Recursive tree walker for mark_opt_subexp. */
-
-static void
-mark_opt_subexp_iter (src, dfa, idx)
- const bin_tree_t *src;
- re_dfa_t *dfa;
- int idx;
-{
- int node_idx;
-
- if (src->type == NON_TYPE)
- {
- node_idx = src->node_idx;
- if ((dfa->nodes[node_idx].type == OP_OPEN_SUBEXP
- || dfa->nodes[node_idx].type == OP_CLOSE_SUBEXP)
- && dfa->nodes[node_idx].opr.idx == idx)
- dfa->nodes[node_idx].opt_subexp = 1;
- }
-
- if (src->left != NULL)
- mark_opt_subexp_iter (src->left, dfa, idx);
-
- if (src->right != NULL)
- mark_opt_subexp_iter (src->right, dfa, idx);
-}
-
-
-/* Duplicate the node SRC, and return new node. */
-
-static bin_tree_t *
-duplicate_tree (src, dfa)
- const bin_tree_t *src;
- re_dfa_t *dfa;
-{
- bin_tree_t *left = NULL, *right = NULL, *new_tree;
- int new_node_idx;
- /* Since node indies must be according to Post-order of the tree,
- we must duplicate the left at first. */
- if (src->left != NULL)
- {
- left = duplicate_tree (src->left, dfa);
- if (left == NULL)
- return NULL;
- }
-
- /* Secondaly, duplicate the right. */
- if (src->right != NULL)
- {
- right = duplicate_tree (src->right, dfa);
- if (right == NULL)
- return NULL;
- }
-
- /* At last, duplicate itself. */
- if (src->type == NON_TYPE)
- {
- new_node_idx = re_dfa_add_node (dfa, dfa->nodes[src->node_idx], 0);
- dfa->nodes[new_node_idx].duplicated = 1;
- if (BE (new_node_idx == -1, 0))
- return NULL;
- }
- else
- new_node_idx = src->type;
-
- new_tree = create_tree (dfa, left, right, src->type, new_node_idx);
- return new_tree;
-}
diff --git a/lib/regex.c b/lib/regex.c
deleted file mode 100644
index 7a4f304..0000000
--- a/lib/regex.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Isamu Hasegawa .
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef _AIX
-#pragma alloca
-#else
-# ifndef allocax /* predefined by HP cc +Olibcalls */
-# ifdef __GNUC__
-# define alloca(size) __builtin_alloca (size)
-# else
-# if HAVE_ALLOCA_H
-# include
-# else
-# ifdef __hpux
- void *alloca ();
-# else
-# if !defined __OS2__ && !defined WIN32
- char *alloca ();
-# else
-# include /* OS/2 defines alloca in here */
-# endif
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef _LIBC
-/* We have to keep the namespace clean. */
-# define regfree(preg) __regfree (preg)
-# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
-# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
-# define regerror(errcode, preg, errbuf, errbuf_size) \
- __regerror(errcode, preg, errbuf, errbuf_size)
-# define re_set_registers(bu, re, nu, st, en) \
- __re_set_registers (bu, re, nu, st, en)
-# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
- __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
-# define re_match(bufp, string, size, pos, regs) \
- __re_match (bufp, string, size, pos, regs)
-# define re_search(bufp, string, size, startpos, range, regs) \
- __re_search (bufp, string, size, startpos, range, regs)
-# define re_compile_pattern(pattern, length, bufp) \
- __re_compile_pattern (pattern, length, bufp)
-# define re_set_syntax(syntax) __re_set_syntax (syntax)
-# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
- __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
-# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
-
-# include "../locale/localeinfo.h"
-#endif
-
-/* POSIX says that must be included (by the caller) before
- . */
-#include
-
-/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
- GNU regex allows. Include it before , which correctly
- #undefs RE_DUP_MAX and sets it to the right value. */
-#include
-
-#include
-#include "regex_internal.h"
-
-#include "regex_internal.c"
-#include "regcomp.c"
-#include "regexec.c"
-
-/* Binary backward compatibility. */
-#if _LIBC
-# include
-# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
-link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
-int re_max_failures = 2000;
-# endif
-#endif
diff --git a/lib/regex_.h b/lib/regex_.h
deleted file mode 100644
index e32af35..0000000
--- a/lib/regex_.h
+++ /dev/null
@@ -1,588 +0,0 @@
-/* Definitions for data structures and routines for the regular
- expression library.
- Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003
- Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _REGEX_H
-#define _REGEX_H 1
-
-#include
-
-/* Allow the use in C++ code. */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* POSIX says that must be included (by the caller) before
- . */
-
-#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
-/* VMS doesn't have `size_t' in , even though POSIX says it
- should be there. */
-# include
-#endif
-
-/* The following two types have to be signed and unsigned integer type
- wide enough to hold a value of a pointer. For most ANSI compilers
- ptrdiff_t and size_t should be likely OK. Still size of these two
- types is 2 for Microsoft C. Ugh... */
-typedef long int s_reg_t;
-typedef unsigned long int active_reg_t;
-
-/* The following bits are used to determine the regexp syntax we
- recognize. The set/not-set meanings are chosen so that Emacs syntax
- remains the value 0. The bits are given in alphabetical order, and
- the definitions shifted by one from the previous bit; thus, when we
- add or remove a bit, only one other definition need change. */
-typedef unsigned long int reg_syntax_t;
-
-/* If this bit is not set, then \ inside a bracket expression is literal.
- If set, then such a \ quotes the following character. */
-#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
-
-/* If this bit is not set, then + and ? are operators, and \+ and \? are
- literals.
- If set, then \+ and \? are operators and + and ? are literals. */
-#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
-
-/* If this bit is set, then character classes are supported. They are:
- [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
- [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
- If not set, then character classes are not supported. */
-#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
-
-/* If this bit is set, then ^ and $ are always anchors (outside bracket
- expressions, of course).
- If this bit is not set, then it depends:
- ^ is an anchor if it is at the beginning of a regular
- expression or after an open-group or an alternation operator;
- $ is an anchor if it is at the end of a regular expression, or
- before a close-group or an alternation operator.
-
- This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
- POSIX draft 11.2 says that * etc. in leading positions is undefined.
- We already implemented a previous draft which made those constructs
- invalid, though, so we haven't changed the code back. */
-#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
-
-/* If this bit is set, then special characters are always special
- regardless of where they are in the pattern.
- If this bit is not set, then special characters are special only in
- some contexts; otherwise they are ordinary. Specifically,
- * + ? and intervals are only special when not after the beginning,
- open-group, or alternation operator. */
-#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
-
-/* If this bit is set, then *, +, ?, and { cannot be first in an re or
- immediately after an alternation or begin-group operator. */
-#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
-
-/* If this bit is set, then . matches newline.
- If not set, then it doesn't. */
-#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
-
-/* If this bit is set, then . doesn't match NUL.
- If not set, then it does. */
-#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
-
-/* If this bit is set, nonmatching lists [^...] do not match newline.
- If not set, they do. */
-#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
-
-/* If this bit is set, either \{...\} or {...} defines an
- interval, depending on RE_NO_BK_BRACES.
- If not set, \{, \}, {, and } are literals. */
-#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
-
-/* If this bit is set, +, ? and | aren't recognized as operators.
- If not set, they are. */
-#define RE_LIMITED_OPS (RE_INTERVALS << 1)
-
-/* If this bit is set, newline is an alternation operator.
- If not set, newline is literal. */
-#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
-
-/* If this bit is set, then `{...}' defines an interval, and \{ and \}
- are literals.
- If not set, then `\{...\}' defines an interval. */
-#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
-
-/* If this bit is set, (...) defines a group, and \( and \) are literals.
- If not set, \(...\) defines a group, and ( and ) are literals. */
-#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
-
-/* If this bit is set, then \ matches .
- If not set, then \ is a back-reference. */
-#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
-
-/* If this bit is set, then | is an alternation operator, and \| is literal.
- If not set, then \| is an alternation operator, and | is literal. */
-#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
-
-/* If this bit is set, then an ending range point collating higher
- than the starting range point, as in [z-a], is invalid.
- If not set, then when ending range point collates higher than the
- starting range point, the range is ignored. */
-#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
-
-/* If this bit is set, then an unmatched ) is ordinary.
- If not set, then an unmatched ) is invalid. */
-#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
-
-/* If this bit is set, succeed as soon as we match the whole pattern,
- without further backtracking. */
-#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
-
-/* If this bit is set, do not process the GNU regex operators.
- If not set, then the GNU regex operators are recognized. */
-#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
-
-/* If this bit is set, turn on internal regex debugging.
- If not set, and debugging was on, turn it off.
- This only works if regex.c is compiled -DDEBUG.
- We define this bit always, so that all that's needed to turn on
- debugging is to recompile regex.c; the calling code can always have
- this bit set, and it won't affect anything in the normal case. */
-#define RE_DEBUG (RE_NO_GNU_OPS << 1)
-
-/* If this bit is set, a syntactically invalid interval is treated as
- a string of ordinary characters. For example, the ERE 'a{1' is
- treated as 'a\{1'. */
-#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
-
-/* If this bit is set, then ignore case when matching.
- If not set, then case is significant. */
-#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
-
-/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
- for ^, because it is difficult to scan the regex backwards to find
- whether ^ should be special. */
-#define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
-
-/* If this bit is set, then \{ cannot be first in an bre or
- immediately after an alternation or begin-group operator. */
-#define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
-
-/* This global variable defines the particular regexp syntax to use (for
- some interfaces). When a regexp is compiled, the syntax used is
- stored in the pattern buffer, so changing this does not affect
- already-compiled regexps. */
-extern reg_syntax_t re_syntax_options;
-
-/* Define combinations of the above bits for the standard possibilities.
- (The [[[ comments delimit what gets put into the Texinfo file, so
- don't delete them!) */
-/* [[[begin syntaxes]]] */
-#define RE_SYNTAX_EMACS 0
-
-#define RE_SYNTAX_AWK \
- (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
- | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
- | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
-
-#define RE_SYNTAX_GNU_AWK \
- ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
- & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \
- | RE_CONTEXT_INVALID_OPS ))
-
-#define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
- | RE_INTERVALS | RE_NO_GNU_OPS)
-
-#define RE_SYNTAX_GREP \
- (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
- | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
- | RE_NEWLINE_ALT)
-
-#define RE_SYNTAX_EGREP \
- (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
- | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
- | RE_NO_BK_VBAR)
-
-#define RE_SYNTAX_POSIX_EGREP \
- (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
- | RE_INVALID_INTERVAL_ORD)
-
-/* 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. */
-#define _RE_SYNTAX_POSIX_COMMON \
- (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
- | RE_INTERVALS | RE_NO_EMPTY_RANGES)
-
-#define RE_SYNTAX_POSIX_BASIC \
- (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
-
-/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
- RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
- isn't minimal, since other operators, such as \`, aren't disabled. */
-#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
- (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
-
-#define RE_SYNTAX_POSIX_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
-
-/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
- removed and RE_NO_BK_REFS is added. */
-#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
-/* [[[end syntaxes]]] */
-
-/* Maximum number of duplicates an interval can allow. Some systems
- (erroneously) define this in other header files, but we want our
- value, so remove any previous define. */
-#ifdef RE_DUP_MAX
-# undef RE_DUP_MAX
-#endif
-/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
-#define RE_DUP_MAX (0x7fff)
-
-
-/* POSIX `cflags' bits (i.e., information for `regcomp'). */
-
-/* If this bit is set, then use extended regular expression syntax.
- If not set, then use basic regular expression syntax. */
-#define REG_EXTENDED 1
-
-/* If this bit is set, then ignore case when matching.
- If not set, then case is significant. */
-#define REG_ICASE (REG_EXTENDED << 1)
-
-/* If this bit is set, then anchors do not match at newline
- characters in the string.
- If not set, then anchors do match at newlines. */
-#define REG_NEWLINE (REG_ICASE << 1)
-
-/* If this bit is set, then report only success or fail in regexec.
- If not set, then returns differ between not matching and errors. */
-#define REG_NOSUB (REG_NEWLINE << 1)
-
-
-/* POSIX `eflags' bits (i.e., information for regexec). */
-
-/* If this bit is set, then the beginning-of-line operator doesn't match
- the beginning of the string (presumably because it's not the
- beginning of a line).
- If not set, then the beginning-of-line operator does match the
- beginning of the string. */
-#define REG_NOTBOL 1
-
-/* Like REG_NOTBOL, except for the end-of-line. */
-#define REG_NOTEOL (1 << 1)
-
-/* Use pmatch[0] to set boundaries for regexec. */
-#define REG_STARTEND (1 << 2)
-
-
-/* If any error codes are removed, changed, or added, update the
- `re_error_msg' table in regex.c. */
-typedef enum
-{
-#ifdef _XOPEN_SOURCE
- REG_ENOSYS = -1, /* This will never happen for this implementation. */
-#endif
-
- REG_NOERROR = 0, /* Success. */
- REG_NOMATCH, /* Didn't find a match (for regexec). */
-
- /* POSIX regcomp return error codes. (In the order listed in the
- standard.) */
- REG_BADPAT, /* Invalid pattern. */
- REG_ECOLLATE, /* Inalid collating element. */
- REG_ECTYPE, /* Invalid character class name. */
- REG_EESCAPE, /* Trailing backslash. */
- REG_ESUBREG, /* Invalid back reference. */
- REG_EBRACK, /* Unmatched left bracket. */
- REG_EPAREN, /* Parenthesis imbalance. */
- REG_EBRACE, /* Unmatched \{. */
- REG_BADBR, /* Invalid contents of \{\}. */
- REG_ERANGE, /* Invalid range end. */
- REG_ESPACE, /* Ran out of memory. */
- REG_BADRPT, /* No preceding re for repetition op. */
-
- /* Error codes we've added. */
- REG_EEND, /* Premature end. */
- REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
- REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
-} reg_errcode_t;
-
-/* This data structure represents a compiled pattern. Before calling
- the pattern compiler, the fields `buffer', `allocated', `fastmap',
- `translate', and `no_sub' can be set. After the pattern has been
- compiled, the `re_nsub' field is available. All other fields are
- private to the regex routines. */
-
-#ifndef RE_TRANSLATE_TYPE
-# define RE_TRANSLATE_TYPE char *
-#endif
-
-struct re_pattern_buffer
-{
-/* [[[begin pattern_buffer]]] */
- /* Space that holds the compiled pattern. It is declared as
- `unsigned char *' because its elements are
- sometimes used as array indexes. */
- unsigned char *buffer;
-
- /* Number of bytes to which `buffer' points. */
- unsigned long int allocated;
-
- /* Number of bytes actually used in `buffer'. */
- unsigned long int used;
-
- /* Syntax setting with which the pattern was compiled. */
- reg_syntax_t syntax;
-
- /* Pointer to a fastmap, if any, otherwise zero. re_search uses
- the fastmap, if there is one, to skip over impossible
- starting points for matches. */
- char *fastmap;
-
- /* Either a translate table to apply to all characters before
- comparing them, or zero for no translation. The translation
- is applied to a pattern when it is compiled and to a string
- when it is matched. */
- RE_TRANSLATE_TYPE translate;
-
- /* Number of subexpressions found by the compiler. */
- size_t re_nsub;
-
- /* Zero if this pattern cannot match the empty string, one else.
- Well, in truth it's used only in `re_search_2', to see
- whether or not we should use the fastmap, so we don't set
- this absolutely perfectly; see `re_compile_fastmap' (the
- `duplicate' case). */
- unsigned can_be_null : 1;
-
- /* If REGS_UNALLOCATED, allocate space in the `regs' structure
- for `max (RE_NREGS, re_nsub + 1)' groups.
- If REGS_REALLOCATE, reallocate space if necessary.
- If REGS_FIXED, use what's there. */
-#define REGS_UNALLOCATED 0
-#define REGS_REALLOCATE 1
-#define REGS_FIXED 2
- unsigned regs_allocated : 2;
-
- /* 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, `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
- beginning of the string. */
- unsigned not_bol : 1;
-
- /* Similarly for an end-of-line anchor. */
- unsigned not_eol : 1;
-
- /* If true, an anchor at a newline matches. */
- unsigned newline_anchor : 1;
-
-/* [[[end pattern_buffer]]] */
-};
-
-typedef struct re_pattern_buffer regex_t;
-
-/* Type for byte offsets within the string. POSIX mandates this. */
-typedef int regoff_t;
-
-
-/* This is the structure we store register match data in. See
- regex.texinfo for a full description of what registers match. */
-struct re_registers
-{
- unsigned num_regs;
- regoff_t *start;
- regoff_t *end;
-};
-
-
-/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
- `re_match_2' returns information about at least this many registers
- the first time a `regs' structure is passed. */
-#ifndef RE_NREGS
-# define RE_NREGS 30
-#endif
-
-
-/* POSIX specification for registers. Aside from the different names than
- `re_registers', POSIX uses an array of structures, instead of a
- structure of arrays. */
-typedef struct
-{
- regoff_t rm_so; /* Byte offset from string's start to substring's start. */
- regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
-} regmatch_t;
-
-/* Declarations for routines. */
-
-/* To avoid duplicating every routine declaration -- once with a
- 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. */
-
-#if __STDC__
-
-# define _RE_ARGS(args) args
-
-#else /* not __STDC__ */
-
-# define _RE_ARGS(args) ()
-
-#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. */
-extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
-
-/* Compile the regular expression PATTERN, with length LENGTH
- and syntax given by the global `re_syntax_options', into the buffer
- BUFFER. Return NULL if successful, and an error string if not. */
-extern const char *re_compile_pattern
- _RE_ARGS ((const char *pattern, size_t length,
- struct re_pattern_buffer *buffer));
-
-
-/* Compile a fastmap for the compiled pattern in BUFFER; used to
- accelerate searches. Return 0 if successful and -2 if was an
- internal error. */
-extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
-
-
-/* Search in the string STRING (with length LENGTH) for the pattern
- compiled into BUFFER. Start searching at position START, for RANGE
- characters. Return the starting position of the match, -1 for no
- match, or -2 for an internal error. Also return register
- information in REGS (if REGS and BUFFER->no_sub are nonzero). */
-extern int re_search
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
- int length, int start, int range, struct re_registers *regs));
-
-
-/* Like `re_search', but search in the concatenation of STRING1 and
- STRING2. Also, stop searching at index START + STOP. */
-extern int re_search_2
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, int range, struct re_registers *regs, int stop));
-
-
-/* Like `re_search', but return how many characters in STRING the regexp
- in BUFFER matched, starting at position START. */
-extern int re_match
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
- int length, int start, struct re_registers *regs));
-
-
-/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
-extern int re_match_2
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, struct re_registers *regs, int stop));
-
-
-/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
- ENDS. Subsequent matches using BUFFER and REGS will use this memory
- for recording register information. STARTS and ENDS must be
- allocated with malloc, and must each be at least `NUM_REGS * sizeof
- (regoff_t)' bytes long.
-
- If NUM_REGS == 0, then subsequent matches should allocate their own
- register data.
-
- Unless this function is called, the first search or match using
- PATTERN_BUFFER will allocate its own register data, without
- freeing the old data. */
-extern void re_set_registers
- _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
- unsigned num_regs, regoff_t *starts, regoff_t *ends));
-
-#if defined _REGEX_RE_COMP || defined _LIBC
-# ifndef _CRAY
-/* 4.2 bsd compatibility. */
-extern char *re_comp _RE_ARGS ((const char *));
-extern int re_exec _RE_ARGS ((const char *));
-# endif
-#endif
-
-/* GCC 2.95 and later have "__restrict"; C99 compilers have
- "restrict", and "configure" may have defined "restrict". */
-#ifndef __restrict
-# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
-# if defined restrict || 199901L <= __STDC_VERSION__
-# define __restrict restrict
-# else
-# define __restrict
-# endif
-# endif
-#endif
-/* gcc 3.1 and up support the [restrict] syntax. */
-#ifndef __restrict_arr
-# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-# define __restrict_arr __restrict
-# else
-# define __restrict_arr
-# endif
-#endif
-
-/* POSIX compatibility. */
-extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
- const char *__restrict __pattern,
- int __cflags));
-
-extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
- const char *__restrict __string, size_t __nmatch,
- regmatch_t __pmatch[__restrict_arr],
- int __eflags));
-
-extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
- char *__errbuf, size_t __errbuf_size));
-
-extern void regfree _RE_ARGS ((regex_t *__preg));
-
-
-#ifdef __cplusplus
-}
-#endif /* C++ */
-
-#endif /* regex.h */
-
-/*
-Local variables:
-make-backup-files: t
-version-control: t
-trim-versions-without-asking: nil
-End:
-*/
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
deleted file mode 100644
index 95c68d7..0000000
--- a/lib/regex_internal.c
+++ /dev/null
@@ -1,1653 +0,0 @@
-/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Isamu Hasegawa .
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-static void re_string_construct_common (const char *str, int len,
- re_string_t *pstr,
- RE_TRANSLATE_TYPE trans, int icase,
- const re_dfa_t *dfa) internal_function;
-#ifdef RE_ENABLE_I18N
-static int re_string_skip_chars (re_string_t *pstr, int new_raw_idx,
- wint_t *last_wc) internal_function;
-#endif /* RE_ENABLE_I18N */
-static re_dfastate_t *create_newstate_common (re_dfa_t *dfa,
- const re_node_set *nodes,
- unsigned int hash) internal_function;
-static reg_errcode_t register_state (re_dfa_t *dfa, re_dfastate_t *newstate,
- unsigned int hash) internal_function;
-static re_dfastate_t *create_ci_newstate (re_dfa_t *dfa,
- const re_node_set *nodes,
- unsigned int hash) internal_function;
-static re_dfastate_t *create_cd_newstate (re_dfa_t *dfa,
- const re_node_set *nodes,
- unsigned int context,
- unsigned int hash) internal_function;
-static unsigned int inline calc_state_hash (const re_node_set *nodes,
- unsigned int context) internal_function;
-
-/* Functions for string operation. */
-
-/* This function allocate the buffers. It is necessary to call
- re_string_reconstruct before using the object. */
-
-static reg_errcode_t
-re_string_allocate (pstr, str, len, init_len, trans, icase, dfa)
- re_string_t *pstr;
- const char *str;
- int len, init_len, icase;
- RE_TRANSLATE_TYPE trans;
- const re_dfa_t *dfa;
-{
- reg_errcode_t ret;
- int init_buf_len;
-
- /* Ensure at least one character fits into the buffers. */
- if (init_len < dfa->mb_cur_max)
- init_len = dfa->mb_cur_max;
- init_buf_len = (len + 1 < init_len) ? len + 1: init_len;
- re_string_construct_common (str, len, pstr, trans, icase, dfa);
-
- ret = re_string_realloc_buffers (pstr, init_buf_len);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
-
- pstr->word_char = dfa->word_char;
- pstr->word_ops_used = dfa->word_ops_used;
- pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
- pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len;
- pstr->valid_raw_len = pstr->valid_len;
- return REG_NOERROR;
-}
-
-/* This function allocate the buffers, and initialize them. */
-
-static reg_errcode_t
-re_string_construct (pstr, str, len, trans, icase, dfa)
- re_string_t *pstr;
- const char *str;
- int len, icase;
- RE_TRANSLATE_TYPE trans;
- const re_dfa_t *dfa;
-{
- reg_errcode_t ret;
- memset (pstr, '\0', sizeof (re_string_t));
- re_string_construct_common (str, len, pstr, trans, icase, dfa);
-
- if (len > 0)
- {
- ret = re_string_realloc_buffers (pstr, len + 1);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
- }
- pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
-
- if (icase)
- {
-#ifdef RE_ENABLE_I18N
- if (dfa->mb_cur_max > 1)
- {
- while (1)
- {
- ret = build_wcs_upper_buffer (pstr);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
- if (pstr->valid_raw_len >= len)
- break;
- if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
- break;
- ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
- }
- }
- else
-#endif /* RE_ENABLE_I18N */
- build_upper_buffer (pstr);
- }
- else
- {
-#ifdef RE_ENABLE_I18N
- if (dfa->mb_cur_max > 1)
- build_wcs_buffer (pstr);
- else
-#endif /* RE_ENABLE_I18N */
- {
- if (trans != NULL)
- re_string_translate_buffer (pstr);
- else
- {
- pstr->valid_len = pstr->bufs_len;
- pstr->valid_raw_len = pstr->bufs_len;
- }
- }
- }
-
- return REG_NOERROR;
-}
-
-/* Helper functions for re_string_allocate, and re_string_construct. */
-
-static reg_errcode_t
-re_string_realloc_buffers (pstr, new_buf_len)
- re_string_t *pstr;
- int new_buf_len;
-{
-#ifdef RE_ENABLE_I18N
- if (pstr->mb_cur_max > 1)
- {
- wint_t *new_array = re_realloc (pstr->wcs, wint_t, new_buf_len);
- if (BE (new_array == NULL, 0))
- return REG_ESPACE;
- pstr->wcs = new_array;
- if (pstr->offsets != NULL)
- {
- int *new_array = re_realloc (pstr->offsets, int, new_buf_len);
- if (BE (new_array == NULL, 0))
- return REG_ESPACE;
- pstr->offsets = new_array;
- }
- }
-#endif /* RE_ENABLE_I18N */
- if (pstr->mbs_allocated)
- {
- unsigned char *new_array = re_realloc (pstr->mbs, unsigned char,
- new_buf_len);
- if (BE (new_array == NULL, 0))
- return REG_ESPACE;
- pstr->mbs = new_array;
- }
- pstr->bufs_len = new_buf_len;
- return REG_NOERROR;
-}
-
-
-static void
-re_string_construct_common (str, len, pstr, trans, icase, dfa)
- const char *str;
- int len;
- re_string_t *pstr;
- RE_TRANSLATE_TYPE trans;
- int icase;
- const re_dfa_t *dfa;
-{
- pstr->raw_mbs = (const unsigned char *) str;
- pstr->len = len;
- pstr->raw_len = len;
- pstr->trans = (unsigned RE_TRANSLATE_TYPE) trans;
- pstr->icase = icase ? 1 : 0;
- pstr->mbs_allocated = (trans != NULL || icase);
- pstr->mb_cur_max = dfa->mb_cur_max;
- pstr->is_utf8 = dfa->is_utf8;
- pstr->map_notascii = dfa->map_notascii;
- pstr->stop = pstr->len;
- pstr->raw_stop = pstr->stop;
-}
-
-#ifdef RE_ENABLE_I18N
-
-/* Build wide character buffer PSTR->WCS.
- If the byte sequence of the string are:
- (0), (1), (0), (1),
- Then wide character buffer will be:
- , WEOF , , WEOF ,
- We use WEOF for padding, they indicate that the position isn't
- a first byte of a multibyte character.
-
- Note that this function assumes PSTR->VALID_LEN elements are already
- built and starts from PSTR->VALID_LEN. */
-
-static void
-build_wcs_buffer (pstr)
- re_string_t *pstr;
-{
-#ifdef _LIBC
- unsigned char buf[pstr->mb_cur_max];
-#else
- unsigned char buf[64];
-#endif
- mbstate_t prev_st;
- int byte_idx, end_idx, mbclen, remain_len;
-
- /* Build the buffers from pstr->valid_len to either pstr->len or
- pstr->bufs_len. */
- end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
- for (byte_idx = pstr->valid_len; byte_idx < end_idx;)
- {
- wchar_t wc;
- const char *p;
-
- remain_len = end_idx - byte_idx;
- prev_st = pstr->cur_state;
- /* Apply the translation if we need. */
- if (BE (pstr->trans != NULL, 0))
- {
- int i, ch;
-
- for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
- {
- ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i];
- buf[i] = pstr->trans[ch];
- }
- p = (const char *) buf;
- }
- else
- p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
- mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
- if (BE (mbclen == (size_t) -2, 0))
- {
- /* The buffer doesn't have enough space, finish to build. */
- pstr->cur_state = prev_st;
- break;
- }
- else if (BE (mbclen == (size_t) -1 || mbclen == 0, 0))
- {
- /* We treat these cases as a singlebyte character. */
- mbclen = 1;
- wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
- if (BE (pstr->trans != NULL, 0))
- wc = pstr->trans[wc];
- pstr->cur_state = prev_st;
- }
-
- /* Write wide character and padding. */
- pstr->wcs[byte_idx++] = wc;
- /* Write paddings. */
- for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
- pstr->wcs[byte_idx++] = WEOF;
- }
- pstr->valid_len = byte_idx;
- pstr->valid_raw_len = byte_idx;
-}
-
-/* Build wide character buffer PSTR->WCS like build_wcs_buffer,
- but for REG_ICASE. */
-
-static int
-build_wcs_upper_buffer (pstr)
- re_string_t *pstr;
-{
- mbstate_t prev_st;
- int src_idx, byte_idx, end_idx, mbclen, remain_len;
-#ifdef _LIBC
- unsigned char buf[pstr->mb_cur_max];
-#else
- unsigned char buf[64];
-#endif
-
- byte_idx = pstr->valid_len;
- end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
-
-#ifdef _LIBC
- /* The following optimization assumes that the wchar_t encoding is
- always ISO 10646. */
- if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
- {
- while (byte_idx < end_idx)
- {
- wchar_t wc;
-
- if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx])
- && mbsinit (&pstr->cur_state))
- {
- /* In case of a singlebyte character. */
- pstr->mbs[byte_idx]
- = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
- /* The next step uses the assumption that wchar_t is encoded
- with ISO 10646: all ASCII values can be converted like
- this. */
- pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
- ++byte_idx;
- continue;
- }
-
- remain_len = end_idx - byte_idx;
- prev_st = pstr->cur_state;
- mbclen = mbrtowc (&wc,
- ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
- + byte_idx), remain_len, &pstr->cur_state);
- if (BE (mbclen > 0, 1))
- {
- wchar_t wcu = wc;
- if (iswlower (wc))
- {
- int mbcdlen;
-
- wcu = towupper (wc);
- mbcdlen = wcrtomb (buf, wcu, &prev_st);
- if (BE (mbclen == mbcdlen, 1))
- memcpy (pstr->mbs + byte_idx, buf, mbclen);
- else
- {
- src_idx = byte_idx;
- goto offsets_needed;
- }
- }
- else
- memcpy (pstr->mbs + byte_idx,
- pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen);
- pstr->wcs[byte_idx++] = wcu;
- /* Write paddings. */
- for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
- pstr->wcs[byte_idx++] = WEOF;
- }
- else if (mbclen == (size_t) -1 || mbclen == 0)
- {
- /* It is an invalid character or '\0'. Just use the byte. */
- int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
- pstr->mbs[byte_idx] = ch;
- /* And also cast it to wide char. */
- pstr->wcs[byte_idx++] = (wchar_t) ch;
- if (BE (mbclen == (size_t) -1, 0))
- pstr->cur_state = prev_st;
- }
- else
- {
- /* The buffer doesn't have enough space, finish to build. */
- pstr->cur_state = prev_st;
- break;
- }
- }
- pstr->valid_len = byte_idx;
- pstr->valid_raw_len = byte_idx;
- return REG_NOERROR;
- }
- else
-#endif
- for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;)
- {
- wchar_t wc;
- const char *p;
-offsets_needed:
- remain_len = end_idx - byte_idx;
- prev_st = pstr->cur_state;
- if (BE (pstr->trans != NULL, 0))
- {
- int i, ch;
-
- for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
- {
- ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i];
- buf[i] = pstr->trans[ch];
- }
- p = (const char *) buf;
- }
- else
- p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
- mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
- if (BE (mbclen > 0, 1))
- {
- wchar_t wcu = wc;
- if (iswlower (wc))
- {
- int mbcdlen;
-
- wcu = towupper (wc);
- mbcdlen = wcrtomb (buf, wcu, &prev_st);
- if (BE (mbclen == mbcdlen, 1))
- memcpy (pstr->mbs + byte_idx, buf, mbclen);
- else
- {
- int i;
-
- if (byte_idx + mbcdlen > pstr->bufs_len)
- {
- pstr->cur_state = prev_st;
- break;
- }
-
- if (pstr->offsets == NULL)
- {
- pstr->offsets = re_malloc (int, pstr->bufs_len);
-
- if (pstr->offsets == NULL)
- return REG_ESPACE;
- }
- if (!pstr->offsets_needed)
- {
- for (i = 0; i < byte_idx; ++i)
- pstr->offsets[i] = i;
- pstr->offsets_needed = 1;
- }
-
- memcpy (pstr->mbs + byte_idx, buf, mbcdlen);
- pstr->wcs[byte_idx] = wcu;
- pstr->offsets[byte_idx] = src_idx;
- for (i = 1; i < mbcdlen; ++i)
- {
- pstr->offsets[byte_idx + i]
- = src_idx + (i < mbclen ? i : mbclen - 1);
- pstr->wcs[byte_idx + i] = WEOF;
- }
- pstr->len += mbcdlen - mbclen;
- if (pstr->raw_stop > src_idx)
- pstr->stop += mbcdlen - mbclen;
- end_idx = (pstr->bufs_len > pstr->len)
- ? pstr->len : pstr->bufs_len;
- byte_idx += mbcdlen;
- src_idx += mbclen;
- continue;
- }
- }
- else
- memcpy (pstr->mbs + byte_idx, p, mbclen);
-
- if (BE (pstr->offsets_needed != 0, 0))
- {
- int i;
- for (i = 0; i < mbclen; ++i)
- pstr->offsets[byte_idx + i] = src_idx + i;
- }
- src_idx += mbclen;
-
- pstr->wcs[byte_idx++] = wcu;
- /* Write paddings. */
- for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
- pstr->wcs[byte_idx++] = WEOF;
- }
- else if (mbclen == (size_t) -1 || mbclen == 0)
- {
- /* It is an invalid character or '\0'. Just use the byte. */
- int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
-
- if (BE (pstr->trans != NULL, 0))
- ch = pstr->trans [ch];
- pstr->mbs[byte_idx] = ch;
-
- if (BE (pstr->offsets_needed != 0, 0))
- pstr->offsets[byte_idx] = src_idx;
- ++src_idx;
-
- /* And also cast it to wide char. */
- pstr->wcs[byte_idx++] = (wchar_t) ch;
- if (BE (mbclen == (size_t) -1, 0))
- pstr->cur_state = prev_st;
- }
- else
- {
- /* The buffer doesn't have enough space, finish to build. */
- pstr->cur_state = prev_st;
- break;
- }
- }
- pstr->valid_len = byte_idx;
- pstr->valid_raw_len = src_idx;
- return REG_NOERROR;
-}
-
-/* Skip characters until the index becomes greater than NEW_RAW_IDX.
- Return the index. */
-
-static int
-re_string_skip_chars (pstr, new_raw_idx, last_wc)
- re_string_t *pstr;
- int new_raw_idx;
- wint_t *last_wc;
-{
- mbstate_t prev_st;
- int rawbuf_idx, mbclen;
- wchar_t wc = 0;
-
- /* Skip the characters which are not necessary to check. */
- for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
- rawbuf_idx < new_raw_idx;)
- {
- int remain_len;
- remain_len = pstr->len - rawbuf_idx;
- prev_st = pstr->cur_state;
- mbclen = mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx,
- remain_len, &pstr->cur_state);
- if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
- {
- /* We treat these cases as a singlebyte character. */
- mbclen = 1;
- pstr->cur_state = prev_st;
- }
- /* Then proceed the next character. */
- rawbuf_idx += mbclen;
- }
- *last_wc = (wint_t) wc;
- return rawbuf_idx;
-}
-#endif /* RE_ENABLE_I18N */
-
-/* Build the buffer PSTR->MBS, and apply the translation if we need.
- This function is used in case of REG_ICASE. */
-
-static void
-build_upper_buffer (pstr)
- re_string_t *pstr;
-{
- int char_idx, end_idx;
- end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
-
- for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
- {
- int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
- if (BE (pstr->trans != NULL, 0))
- ch = pstr->trans[ch];
- if (islower (ch))
- pstr->mbs[char_idx] = toupper (ch);
- else
- pstr->mbs[char_idx] = ch;
- }
- pstr->valid_len = char_idx;
- pstr->valid_raw_len = char_idx;
-}
-
-/* Apply TRANS to the buffer in PSTR. */
-
-static void
-re_string_translate_buffer (pstr)
- re_string_t *pstr;
-{
- int buf_idx, end_idx;
- end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
-
- for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx)
- {
- int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx];
- pstr->mbs[buf_idx] = pstr->trans[ch];
- }
-
- pstr->valid_len = buf_idx;
- pstr->valid_raw_len = buf_idx;
-}
-
-/* This function re-construct the buffers.
- Concretely, convert to wide character in case of pstr->mb_cur_max > 1,
- convert to upper case in case of REG_ICASE, apply translation. */
-
-static reg_errcode_t
-re_string_reconstruct (pstr, idx, eflags)
- re_string_t *pstr;
- int idx, eflags;
-{
- int offset = idx - pstr->raw_mbs_idx;
- if (BE (offset < 0, 0))
- {
- /* Reset buffer. */
-#ifdef RE_ENABLE_I18N
- if (pstr->mb_cur_max > 1)
- memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
-#endif /* RE_ENABLE_I18N */
- pstr->len = pstr->raw_len;
- pstr->stop = pstr->raw_stop;
- pstr->valid_len = 0;
- pstr->raw_mbs_idx = 0;
- pstr->valid_raw_len = 0;
- pstr->offsets_needed = 0;
- pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
- : CONTEXT_NEWLINE | CONTEXT_BEGBUF);
- if (!pstr->mbs_allocated)
- pstr->mbs = (unsigned char *) pstr->raw_mbs;
- offset = idx;
- }
-
- if (BE (offset != 0, 1))
- {
- /* Are the characters which are already checked remain? */
- if (BE (offset < pstr->valid_raw_len, 1)
-#ifdef RE_ENABLE_I18N
- /* Handling this would enlarge the code too much.
- Accept a slowdown in that case. */
- && pstr->offsets_needed == 0
-#endif
- )
- {
- /* Yes, move them to the front of the buffer. */
- pstr->tip_context = re_string_context_at (pstr, offset - 1, eflags);
-#ifdef RE_ENABLE_I18N
- if (BE (pstr->mb_cur_max, 1) > 1)
- memmove (pstr->wcs, pstr->wcs + offset,
- (pstr->valid_len - offset) * sizeof (wint_t));
-#endif /* RE_ENABLE_I18N */
- if (BE (pstr->mbs_allocated, 0))
- memmove (pstr->mbs, pstr->mbs + offset,
- pstr->valid_len - offset);
- pstr->valid_len -= offset;
- pstr->valid_raw_len -= offset;
-#if DEBUG
- assert (pstr->valid_len > 0);
-#endif
- }
- else
- {
- /* No, skip all characters until IDX. */
-#ifdef RE_ENABLE_I18N
- if (BE (pstr->offsets_needed, 0))
- {
- pstr->len = pstr->raw_len - idx + offset;
- pstr->stop = pstr->raw_stop - idx + offset;
- pstr->offsets_needed = 0;
- }
-#endif
- pstr->valid_len = 0;
- pstr->valid_raw_len = 0;
-#ifdef RE_ENABLE_I18N
- if (pstr->mb_cur_max > 1)
- {
- int wcs_idx;
- wint_t wc = WEOF;
-
-#ifdef _LIBC
- if (pstr->is_utf8)
- {
- const unsigned char *raw, *p, *q, *end;
-
- /* Special case UTF-8. Multi-byte chars start with any
- byte other than 0x80 - 0xbf. */
- raw = pstr->raw_mbs + pstr->raw_mbs_idx;
- end = raw + (offset - pstr->mb_cur_max);
- for (p = raw + offset - 1; p >= end; --p)
- if ((*p & 0xc0) != 0x80)
- {
- mbstate_t cur_state;
- wchar_t wc2;
- int mlen = raw + pstr->len - p;
- unsigned char buf[6];
-
- q = p;
- if (BE (pstr->trans != NULL, 0))
- {
- int i = mlen < 6 ? mlen : 6;
- while (--i >= 0)
- buf[i] = pstr->trans[p[i]];
- q = buf;
- }
- /* XXX Don't use mbrtowc, we know which conversion
- to use (UTF-8 -> UCS4). */
- memset (&cur_state, 0, sizeof (cur_state));
- mlen = mbrtowc (&wc2, p, mlen, &cur_state)
- - (raw + offset - p);
- if (mlen >= 0)
- {
- memset (&pstr->cur_state, '\0',
- sizeof (mbstate_t));
- pstr->valid_len = mlen;
- wc = wc2;
- }
- break;
- }
- }
-#endif
- if (wc == WEOF)
- pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;
- if (BE (pstr->valid_len, 0))
- {
- for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
- pstr->wcs[wcs_idx] = WEOF;
- if (pstr->mbs_allocated)
- memset (pstr->mbs, 255, pstr->valid_len);
- }
- pstr->valid_raw_len = pstr->valid_len;
- pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
- && IS_WIDE_WORD_CHAR (wc))
- ? CONTEXT_WORD
- : ((IS_WIDE_NEWLINE (wc)
- && pstr->newline_anchor)
- ? CONTEXT_NEWLINE : 0));
- }
- else
-#endif /* RE_ENABLE_I18N */
- {
- int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
- if (pstr->trans)
- c = pstr->trans[c];
- pstr->tip_context = (bitset_contain (pstr->word_char, c)
- ? CONTEXT_WORD
- : ((IS_NEWLINE (c) && pstr->newline_anchor)
- ? CONTEXT_NEWLINE : 0));
- }
- }
- if (!BE (pstr->mbs_allocated, 0))
- pstr->mbs += offset;
- }
- pstr->raw_mbs_idx = idx;
- pstr->len -= offset;
- pstr->stop -= offset;
-
- /* Then build the buffers. */
-#ifdef RE_ENABLE_I18N
- if (BE (pstr->mb_cur_max, 1) > 1)
- {
- if (pstr->icase)
- {
- int ret = build_wcs_upper_buffer (pstr);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
- }
- else
- build_wcs_buffer (pstr);
- }
- else
-#endif /* RE_ENABLE_I18N */
- if (BE (pstr->mbs_allocated, 0))
- {
- if (pstr->icase)
- build_upper_buffer (pstr);
- else if (pstr->trans != NULL)
- re_string_translate_buffer (pstr);
- }
- else
- pstr->valid_len = pstr->len;
-
- pstr->cur_idx = 0;
- return REG_NOERROR;
-}
-
-static unsigned char
-re_string_peek_byte_case (pstr, idx)
- const re_string_t *pstr;
- int idx;
-{
- int ch, off;
-
- /* Handle the common (easiest) cases first. */
- if (BE (!pstr->mbs_allocated, 1))
- return re_string_peek_byte (pstr, idx);
-
-#ifdef RE_ENABLE_I18N
- if (pstr->mb_cur_max > 1
- && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
- return re_string_peek_byte (pstr, idx);
-#endif
-
- off = pstr->cur_idx + idx;
-#ifdef RE_ENABLE_I18N
- if (pstr->offsets_needed)
- off = pstr->offsets[off];
-#endif
-
- ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
-
-#ifdef RE_ENABLE_I18N
- /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
- this function returns CAPITAL LETTER I instead of first byte of
- DOTLESS SMALL LETTER I. The latter would confuse the parser,
- since peek_byte_case doesn't advance cur_idx in any way. */
- if (pstr->offsets_needed && !isascii (ch))
- return re_string_peek_byte (pstr, idx);
-#endif
-
- return ch;
-}
-
-static unsigned char
-re_string_fetch_byte_case (pstr)
- re_string_t *pstr;
-{
- if (BE (!pstr->mbs_allocated, 1))
- return re_string_fetch_byte (pstr);
-
-#ifdef RE_ENABLE_I18N
- if (pstr->offsets_needed)
- {
- int off, ch;
-
- /* For tr_TR.UTF-8 [[:islower:]] there is
- [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip
- in that case the whole multi-byte character and return
- the original letter. On the other side, with
- [[: DOTLESS SMALL LETTER I return [[:I, as doing
- anything else would complicate things too much. */
-
- if (!re_string_first_byte (pstr, pstr->cur_idx))
- return re_string_fetch_byte (pstr);
-
- off = pstr->offsets[pstr->cur_idx];
- ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
-
- if (! isascii (ch))
- return re_string_fetch_byte (pstr);
-
- re_string_skip_bytes (pstr,
- re_string_char_size_at (pstr, pstr->cur_idx));
- return ch;
- }
-#endif
-
- return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
-}
-
-static void
-re_string_destruct (pstr)
- re_string_t *pstr;
-{
-#ifdef RE_ENABLE_I18N
- re_free (pstr->wcs);
- re_free (pstr->offsets);
-#endif /* RE_ENABLE_I18N */
- if (pstr->mbs_allocated)
- re_free (pstr->mbs);
-}
-
-/* Return the context at IDX in INPUT. */
-
-static unsigned int
-re_string_context_at (input, idx, eflags)
- const re_string_t *input;
- int idx, eflags;
-{
- int c;
- if (BE (idx < 0, 0))
- /* In this case, we use the value stored in input->tip_context,
- since we can't know the character in input->mbs[-1] here. */
- return input->tip_context;
-
- else if (BE (idx == input->len, 0))
- return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
- : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
-
-#ifdef RE_ENABLE_I18N
- else if (BE (input->mb_cur_max, 1) > 1)
- {
- wint_t wc;
- int wc_idx = idx;
- while(input->wcs[wc_idx] == WEOF)
- {
-#ifdef DEBUG
- /* It must not happen. */
- assert (wc_idx >= 0);
-#endif
- --wc_idx;
- if (wc_idx < 0)
- return input->tip_context;
- }
- wc = input->wcs[wc_idx];
- if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc))
- return CONTEXT_WORD;
- return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
- ? CONTEXT_NEWLINE : 0);
- }
- else
-#endif
- {
- c = re_string_byte_at (input, idx);
- if (bitset_contain (input->word_char, c))
- return CONTEXT_WORD;
- return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
- }
-}
-
-/* Functions for set operation. */
-
-static reg_errcode_t
-re_node_set_alloc (set, size)
- re_node_set *set;
- int size;
-{
- set->alloc = size;
- set->nelem = 0;
- set->elems = re_malloc (int, size);
- if (BE (set->elems == NULL, 0))
- return REG_ESPACE;
- return REG_NOERROR;
-}
-
-static reg_errcode_t
-re_node_set_init_1 (set, elem)
- re_node_set *set;
- int elem;
-{
- set->alloc = 1;
- set->nelem = 1;
- set->elems = re_malloc (int, 1);
- if (BE (set->elems == NULL, 0))
- {
- set->alloc = set->nelem = 0;
- return REG_ESPACE;
- }
- set->elems[0] = elem;
- return REG_NOERROR;
-}
-
-static reg_errcode_t
-re_node_set_init_2 (set, elem1, elem2)
- re_node_set *set;
- int elem1, elem2;
-{
- set->alloc = 2;
- set->elems = re_malloc (int, 2);
- if (BE (set->elems == NULL, 0))
- return REG_ESPACE;
- if (elem1 == elem2)
- {
- set->nelem = 1;
- set->elems[0] = elem1;
- }
- else
- {
- set->nelem = 2;
- if (elem1 < elem2)
- {
- set->elems[0] = elem1;
- set->elems[1] = elem2;
- }
- else
- {
- set->elems[0] = elem2;
- set->elems[1] = elem1;
- }
- }
- return REG_NOERROR;
-}
-
-static reg_errcode_t
-re_node_set_init_copy (dest, src)
- re_node_set *dest;
- const re_node_set *src;
-{
- dest->nelem = src->nelem;
- if (src->nelem > 0)
- {
- dest->alloc = dest->nelem;
- dest->elems = re_malloc (int, dest->alloc);
- if (BE (dest->elems == NULL, 0))
- {
- dest->alloc = dest->nelem = 0;
- return REG_ESPACE;
- }
- memcpy (dest->elems, src->elems, src->nelem * sizeof (int));
- }
- else
- re_node_set_init_empty (dest);
- return REG_NOERROR;
-}
-
-/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to
- DEST. Return value indicate the error code or REG_NOERROR if succeeded.
- Note: We assume dest->elems is NULL, when dest->alloc is 0. */
-
-static reg_errcode_t
-re_node_set_add_intersect (dest, src1, src2)
- re_node_set *dest;
- const re_node_set *src1, *src2;
-{
- int i1, i2, is, id, delta, sbase;
- if (src1->nelem == 0 || src2->nelem == 0)
- return REG_NOERROR;
-
- /* We need dest->nelem + 2 * elems_in_intersection; this is a
- conservative estimate. */
- if (src1->nelem + src2->nelem + dest->nelem > dest->alloc)
- {
- int new_alloc = src1->nelem + src2->nelem + dest->alloc;
- int *new_elems = re_realloc (dest->elems, int, new_alloc);
- if (BE (new_elems == NULL, 0))
- return REG_ESPACE;
- dest->elems = new_elems;
- dest->alloc = new_alloc;
- }
-
- /* Find the items in the intersection of SRC1 and SRC2, and copy
- into the top of DEST those that are not already in DEST itself. */
- sbase = dest->nelem + src1->nelem + src2->nelem;
- i1 = src1->nelem - 1;
- i2 = src2->nelem - 1;
- id = dest->nelem - 1;
- for (;;)
- {
- if (src1->elems[i1] == src2->elems[i2])
- {
- /* Try to find the item in DEST. Maybe we could binary search? */
- while (id >= 0 && dest->elems[id] > src1->elems[i1])
- --id;
-
- if (id < 0 || dest->elems[id] != src1->elems[i1])
- dest->elems[--sbase] = src1->elems[i1];
-
- if (--i1 < 0 || --i2 < 0)
- break;
- }
-
- /* Lower the highest of the two items. */
- else if (src1->elems[i1] < src2->elems[i2])
- {
- if (--i2 < 0)
- break;
- }
- else
- {
- if (--i1 < 0)
- break;
- }
- }
-
- id = dest->nelem - 1;
- is = dest->nelem + src1->nelem + src2->nelem - 1;
- delta = is - sbase + 1;
-
- /* Now copy. When DELTA becomes zero, the remaining
- DEST elements are already in place; this is more or
- less the same loop that is in re_node_set_merge. */
- dest->nelem += delta;
- if (delta > 0 && id >= 0)
- for (;;)
- {
- if (dest->elems[is] > dest->elems[id])
- {
- /* Copy from the top. */
- dest->elems[id + delta--] = dest->elems[is--];
- if (delta == 0)
- break;
- }
- else
- {
- /* Slide from the bottom. */
- dest->elems[id + delta] = dest->elems[id];
- if (--id < 0)
- break;
- }
- }
-
- /* Copy remaining SRC elements. */
- memcpy (dest->elems, dest->elems + sbase, delta * sizeof (int));
-
- return REG_NOERROR;
-}
-
-/* Calculate the union set of the sets SRC1 and SRC2. And store it to
- DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
-
-static reg_errcode_t
-re_node_set_init_union (dest, src1, src2)
- re_node_set *dest;
- const re_node_set *src1, *src2;
-{
- int i1, i2, id;
- if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
- {
- dest->alloc = src1->nelem + src2->nelem;
- dest->elems = re_malloc (int, dest->alloc);
- if (BE (dest->elems == NULL, 0))
- return REG_ESPACE;
- }
- else
- {
- if (src1 != NULL && src1->nelem > 0)
- return re_node_set_init_copy (dest, src1);
- else if (src2 != NULL && src2->nelem > 0)
- return re_node_set_init_copy (dest, src2);
- else
- re_node_set_init_empty (dest);
- return REG_NOERROR;
- }
- for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
- {
- if (src1->elems[i1] > src2->elems[i2])
- {
- dest->elems[id++] = src2->elems[i2++];
- continue;
- }
- if (src1->elems[i1] == src2->elems[i2])
- ++i2;
- dest->elems[id++] = src1->elems[i1++];
- }
- if (i1 < src1->nelem)
- {
- memcpy (dest->elems + id, src1->elems + i1,
- (src1->nelem - i1) * sizeof (int));
- id += src1->nelem - i1;
- }
- else if (i2 < src2->nelem)
- {
- memcpy (dest->elems + id, src2->elems + i2,
- (src2->nelem - i2) * sizeof (int));
- id += src2->nelem - i2;
- }
- dest->nelem = id;
- return REG_NOERROR;
-}
-
-/* Calculate the union set of the sets DEST and SRC. And store it to
- DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
-
-static reg_errcode_t
-re_node_set_merge (dest, src)
- re_node_set *dest;
- const re_node_set *src;
-{
- int is, id, sbase, delta;
- if (src == NULL || src->nelem == 0)
- return REG_NOERROR;
- if (dest->alloc < 2 * src->nelem + dest->nelem)
- {
- int new_alloc = 2 * (src->nelem + dest->alloc);
- int *new_buffer = re_realloc (dest->elems, int, new_alloc);
- if (BE (new_buffer == NULL, 0))
- return REG_ESPACE;
- dest->elems = new_buffer;
- dest->alloc = new_alloc;
- }
-
- if (BE (dest->nelem == 0, 0))
- {
- dest->nelem = src->nelem;
- memcpy (dest->elems, src->elems, src->nelem * sizeof (int));
- return REG_NOERROR;
- }
-
- /* Copy into the top of DEST the items of SRC that are not
- found in DEST. Maybe we could binary search in DEST? */
- for (sbase = dest->nelem + 2 * src->nelem,
- is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; )
- {
- if (dest->elems[id] == src->elems[is])
- is--, id--;
- else if (dest->elems[id] < src->elems[is])
- dest->elems[--sbase] = src->elems[is--];
- else /* if (dest->elems[id] > src->elems[is]) */
- --id;
- }
-
- if (is >= 0)
- {
- /* If DEST is exhausted, the remaining items of SRC must be unique. */
- sbase -= is + 1;
- memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (int));
- }
-
- id = dest->nelem - 1;
- is = dest->nelem + 2 * src->nelem - 1;
- delta = is - sbase + 1;
- if (delta == 0)
- return REG_NOERROR;
-
- /* Now copy. When DELTA becomes zero, the remaining
- DEST elements are already in place. */
- dest->nelem += delta;
- for (;;)
- {
- if (dest->elems[is] > dest->elems[id])
- {
- /* Copy from the top. */
- dest->elems[id + delta--] = dest->elems[is--];
- if (delta == 0)
- break;
- }
- else
- {
- /* Slide from the bottom. */
- dest->elems[id + delta] = dest->elems[id];
- if (--id < 0)
- {
- /* Copy remaining SRC elements. */
- memcpy (dest->elems, dest->elems + sbase,
- delta * sizeof (int));
- break;
- }
- }
- }
-
- return REG_NOERROR;
-}
-
-/* Insert the new element ELEM to the re_node_set* SET.
- SET should not already have ELEM.
- return -1 if an error is occured, return 1 otherwise. */
-
-static int
-re_node_set_insert (set, elem)
- re_node_set *set;
- int elem;
-{
- int idx;
- /* In case the set is empty. */
- if (set->alloc == 0)
- {
- if (BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1))
- return 1;
- else
- return -1;
- }
-
- if (BE (set->nelem, 0) == 0)
- {
- /* We already guaranteed above that set->alloc != 0. */
- set->elems[0] = elem;
- ++set->nelem;
- return 1;
- }
-
- /* Realloc if we need. */
- if (set->alloc == set->nelem)
- {
- int *new_array;
- set->alloc = set->alloc * 2;
- new_array = re_realloc (set->elems, int, set->alloc);
- if (BE (new_array == NULL, 0))
- return -1;
- set->elems = new_array;
- }
-
- /* Move the elements which follows the new element. Test the
- first element separately to skip a check in the inner loop. */
- if (elem < set->elems[0])
- {
- idx = 0;
- for (idx = set->nelem; idx > 0; idx--)
- set->elems[idx] = set->elems[idx - 1];
- }
- else
- {
- for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
- set->elems[idx] = set->elems[idx - 1];
- }
-
- /* Insert the new element. */
- set->elems[idx] = elem;
- ++set->nelem;
- return 1;
-}
-
-/* Compare two node sets SET1 and SET2.
- return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */
-
-static int
-re_node_set_compare (set1, set2)
- const re_node_set *set1, *set2;
-{
- int i;
- if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
- return 0;
- for (i = set1->nelem ; --i >= 0 ; )
- if (set1->elems[i] != set2->elems[i])
- return 0;
- return 1;
-}
-
-/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
-
-static int
-re_node_set_contains (set, elem)
- const re_node_set *set;
- int elem;
-{
- int idx, right, mid;
- if (set->nelem <= 0)
- return 0;
-
- /* Binary search the element. */
- idx = 0;
- right = set->nelem - 1;
- while (idx < right)
- {
- mid = (idx + right) / 2;
- if (set->elems[mid] < elem)
- idx = mid + 1;
- else
- right = mid;
- }
- return set->elems[idx] == elem ? idx + 1 : 0;
-}
-
-static void
-re_node_set_remove_at (set, idx)
- re_node_set *set;
- int idx;
-{
- if (idx < 0 || idx >= set->nelem)
- return;
- --set->nelem;
- for (; idx < set->nelem; idx++)
- set->elems[idx] = set->elems[idx + 1];
-}
-
-
-/* Add the token TOKEN to dfa->nodes, and return the index of the token.
- Or return -1, if an error will be occured. */
-
-static int
-re_dfa_add_node (dfa, token, mode)
- re_dfa_t *dfa;
- re_token_t token;
- int mode;
-{
- if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
- {
- int new_nodes_alloc = dfa->nodes_alloc * 2;
- re_token_t *new_array = re_realloc (dfa->nodes, re_token_t,
- new_nodes_alloc);
- if (BE (new_array == NULL, 0))
- return -1;
- dfa->nodes = new_array;
- if (mode)
- {
- int *new_nexts, *new_indices;
- re_node_set *new_edests, *new_eclosures, *new_inveclosures;
-
- new_nexts = re_realloc (dfa->nexts, int, new_nodes_alloc);
- new_indices = re_realloc (dfa->org_indices, int, new_nodes_alloc);
- new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
- new_eclosures = re_realloc (dfa->eclosures, re_node_set,
- new_nodes_alloc);
- new_inveclosures = re_realloc (dfa->inveclosures, re_node_set,
- new_nodes_alloc);
- if (BE (new_nexts == NULL || new_indices == NULL
- || new_edests == NULL || new_eclosures == NULL
- || new_inveclosures == NULL, 0))
- return -1;
- dfa->nexts = new_nexts;
- dfa->org_indices = new_indices;
- dfa->edests = new_edests;
- dfa->eclosures = new_eclosures;
- dfa->inveclosures = new_inveclosures;
- }
- dfa->nodes_alloc = new_nodes_alloc;
- }
- dfa->nodes[dfa->nodes_len] = token;
- dfa->nodes[dfa->nodes_len].opt_subexp = 0;
- dfa->nodes[dfa->nodes_len].duplicated = 0;
- dfa->nodes[dfa->nodes_len].constraint = 0;
- return dfa->nodes_len++;
-}
-
-static unsigned int inline
-calc_state_hash (nodes, context)
- const re_node_set *nodes;
- unsigned int context;
-{
- unsigned int hash = nodes->nelem + context;
- int i;
- for (i = 0 ; i < nodes->nelem ; i++)
- hash += nodes->elems[i];
- return hash;
-}
-
-/* Search for the state whose node_set is equivalent to NODES.
- Return the pointer to the state, if we found it in the DFA.
- Otherwise create the new one and return it. In case of an error
- return NULL and set the error code in ERR.
- Note: - We assume NULL as the invalid state, then it is possible that
- return value is NULL and ERR is REG_NOERROR.
- - We never return non-NULL value in case of any errors, it is for
- optimization. */
-
-static re_dfastate_t*
-re_acquire_state (err, dfa, nodes)
- reg_errcode_t *err;
- re_dfa_t *dfa;
- const re_node_set *nodes;
-{
- unsigned int hash;
- re_dfastate_t *new_state;
- struct re_state_table_entry *spot;
- int i;
- if (BE (nodes->nelem == 0, 0))
- {
- *err = REG_NOERROR;
- return NULL;
- }
- hash = calc_state_hash (nodes, 0);
- spot = dfa->state_table + (hash & dfa->state_hash_mask);
-
- for (i = 0 ; i < spot->num ; i++)
- {
- re_dfastate_t *state = spot->array[i];
- if (hash != state->hash)
- continue;
- if (re_node_set_compare (&state->nodes, nodes))
- return state;
- }
-
- /* There are no appropriate state in the dfa, create the new one. */
- new_state = create_ci_newstate (dfa, nodes, hash);
- if (BE (new_state != NULL, 1))
- return new_state;
- else
- {
- *err = REG_ESPACE;
- return NULL;
- }
-}
-
-/* Search for the state whose node_set is equivalent to NODES and
- whose context is equivalent to CONTEXT.
- Return the pointer to the state, if we found it in the DFA.
- Otherwise create the new one and return it. In case of an error
- return NULL and set the error code in ERR.
- Note: - We assume NULL as the invalid state, then it is possible that
- return value is NULL and ERR is REG_NOERROR.
- - We never return non-NULL value in case of any errors, it is for
- optimization. */
-
-static re_dfastate_t*
-re_acquire_state_context (err, dfa, nodes, context)
- reg_errcode_t *err;
- re_dfa_t *dfa;
- const re_node_set *nodes;
- unsigned int context;
-{
- unsigned int hash;
- re_dfastate_t *new_state;
- struct re_state_table_entry *spot;
- int i;
- if (nodes->nelem == 0)
- {
- *err = REG_NOERROR;
- return NULL;
- }
- hash = calc_state_hash (nodes, context);
- spot = dfa->state_table + (hash & dfa->state_hash_mask);
-
- for (i = 0 ; i < spot->num ; i++)
- {
- re_dfastate_t *state = spot->array[i];
- if (state->hash == hash
- && state->context == context
- && re_node_set_compare (state->entrance_nodes, nodes))
- return state;
- }
- /* There are no appropriate state in `dfa', create the new one. */
- new_state = create_cd_newstate (dfa, nodes, context, hash);
- if (BE (new_state != NULL, 1))
- return new_state;
- else
- {
- *err = REG_ESPACE;
- return NULL;
- }
-}
-
-/* Allocate memory for DFA state and initialize common properties.
- Return the new state if succeeded, otherwise return NULL. */
-
-static re_dfastate_t *
-create_newstate_common (dfa, nodes, hash)
- re_dfa_t *dfa;
- const re_node_set *nodes;
- unsigned int hash;
-{
- re_dfastate_t *newstate;
- reg_errcode_t err;
- newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
- if (BE (newstate == NULL, 0))
- return NULL;
- err = re_node_set_init_copy (&newstate->nodes, nodes);
- if (BE (err != REG_NOERROR, 0))
- {
- re_free (newstate);
- return NULL;
- }
- newstate->trtable = NULL;
- newstate->hash = hash;
- return newstate;
-}
-
-/* Store the new state NEWSTATE whose hash value is HASH in appropriate
- position. Return value indicate the error code if failed. */
-
-static reg_errcode_t
-register_state (dfa, newstate, hash)
- re_dfa_t *dfa;
- re_dfastate_t *newstate;
- unsigned int hash;
-{
- struct re_state_table_entry *spot;
- spot = dfa->state_table + (hash & dfa->state_hash_mask);
-
- if (BE (spot->alloc <= spot->num, 0))
- {
- int new_alloc = 2 * spot->num + 2;
- re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
- new_alloc);
- if (BE (new_array == NULL, 0))
- return REG_ESPACE;
- spot->array = new_array;
- spot->alloc = new_alloc;
- }
- spot->array[spot->num++] = newstate;
- return REG_NOERROR;
-}
-
-/* Create the new state which is independ of contexts.
- Return the new state if succeeded, otherwise return NULL. */
-
-static re_dfastate_t *
-create_ci_newstate (dfa, nodes, hash)
- re_dfa_t *dfa;
- const re_node_set *nodes;
- unsigned int hash;
-{
- int i;
- reg_errcode_t err;
- re_dfastate_t *newstate;
- newstate = create_newstate_common (dfa, nodes, hash);
- if (BE (newstate == NULL, 0))
- return NULL;
- newstate->entrance_nodes = &newstate->nodes;
-
- for (i = 0 ; i < nodes->nelem ; i++)
- {
- re_token_t *node = dfa->nodes + nodes->elems[i];
- re_token_type_t type = node->type;
- if (type == CHARACTER && !node->constraint)
- continue;
-
- /* If the state has the halt node, the state is a halt state. */
- else if (type == END_OF_RE)
- newstate->halt = 1;
-#ifdef RE_ENABLE_I18N
- else if (type == COMPLEX_BRACKET
- || type == OP_UTF8_PERIOD
- || (type == OP_PERIOD && dfa->mb_cur_max > 1))
- newstate->accept_mb = 1;
-#endif /* RE_ENABLE_I18N */
- else if (type == OP_BACK_REF)
- newstate->has_backref = 1;
- else if (type == ANCHOR || node->constraint)
- newstate->has_constraint = 1;
- }
- err = register_state (dfa, newstate, hash);
- if (BE (err != REG_NOERROR, 0))
- {
- free_state (newstate);
- newstate = NULL;
- }
- return newstate;
-}
-
-/* Create the new state which is depend on the context CONTEXT.
- Return the new state if succeeded, otherwise return NULL. */
-
-static re_dfastate_t *
-create_cd_newstate (dfa, nodes, context, hash)
- re_dfa_t *dfa;
- const re_node_set *nodes;
- unsigned int context, hash;
-{
- int i, nctx_nodes = 0;
- reg_errcode_t err;
- re_dfastate_t *newstate;
-
- newstate = create_newstate_common (dfa, nodes, hash);
- if (BE (newstate == NULL, 0))
- return NULL;
- newstate->context = context;
- newstate->entrance_nodes = &newstate->nodes;
-
- for (i = 0 ; i < nodes->nelem ; i++)
- {
- unsigned int constraint = 0;
- re_token_t *node = dfa->nodes + nodes->elems[i];
- re_token_type_t type = node->type;
- if (node->constraint)
- constraint = node->constraint;
-
- if (type == CHARACTER && !constraint)
- continue;
- /* If the state has the halt node, the state is a halt state. */
- else if (type == END_OF_RE)
- newstate->halt = 1;
-#ifdef RE_ENABLE_I18N
- else if (type == COMPLEX_BRACKET
- || type == OP_UTF8_PERIOD
- || (type == OP_PERIOD && dfa->mb_cur_max > 1))
- newstate->accept_mb = 1;
-#endif /* RE_ENABLE_I18N */
- else if (type == OP_BACK_REF)
- newstate->has_backref = 1;
- else if (type == ANCHOR)
- constraint = node->opr.ctx_type;
-
- if (constraint)
- {
- if (newstate->entrance_nodes == &newstate->nodes)
- {
- newstate->entrance_nodes = re_malloc (re_node_set, 1);
- if (BE (newstate->entrance_nodes == NULL, 0))
- {
- free_state (newstate);
- return NULL;
- }
- re_node_set_init_copy (newstate->entrance_nodes, nodes);
- nctx_nodes = 0;
- newstate->has_constraint = 1;
- }
-
- if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
- {
- re_node_set_remove_at (&newstate->nodes, i - nctx_nodes);
- ++nctx_nodes;
- }
- }
- }
- err = register_state (dfa, newstate, hash);
- if (BE (err != REG_NOERROR, 0))
- {
- free_state (newstate);
- newstate = NULL;
- }
- return newstate;
-}
-
-static void
-free_state (state)
- re_dfastate_t *state;
-{
- if (state->entrance_nodes != &state->nodes)
- {
- re_node_set_free (state->entrance_nodes);
- re_free (state->entrance_nodes);
- }
- re_node_set_free (&state->nodes);
- re_free (state->trtable);
- re_free (state->word_trtable);
- re_free (state);
-}
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
deleted file mode 100644
index 84d02cc..0000000
--- a/lib/regex_internal.h
+++ /dev/null
@@ -1,807 +0,0 @@
-/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Isamu Hasegawa .
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _REGEX_INTERNAL_H
-#define _REGEX_INTERNAL_H 1
-
-#include
-#include
-#include
-#include
-#include
-
-#if defined HAVE_LOCALE_H || defined _LIBC
-# include
-#endif
-#if defined HAVE_WCHAR_H || defined _LIBC
-# include
-#endif /* HAVE_WCHAR_H || _LIBC */
-#if defined HAVE_WCTYPE_H || defined _LIBC
-# include
-#endif /* HAVE_WCTYPE_H || _LIBC */
-
-/* In case that the system doesn't have isblank(). */
-#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank
-# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
-#endif
-
-#ifdef _LIBC
-# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
-# define _RE_DEFINE_LOCALE_FUNCTIONS 1
-# include
-# include
-# include
-# endif
-#endif
-
-/* This is for other GNU distributions with internationalized messages. */
-#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
-# include
-# ifdef _LIBC
-# undef gettext
-# define gettext(msgid) \
- INTUSE(__dcgettext) (INTUSE(_libc_intl_domainname), msgid, LC_MESSAGES)
-# endif
-#else
-# define gettext(msgid) (msgid)
-#endif
-
-#ifndef gettext_noop
-/* This define is so xgettext can find the internationalizable
- strings. */
-# define gettext_noop(String) String
-#endif
-
-#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC
-# define RE_ENABLE_I18N
-#endif
-
-#if __GNUC__ >= 3
-# define BE(expr, val) __builtin_expect (expr, val)
-#else
-# define BE(expr, val) (expr)
-# define inline
-#endif
-
-/* Number of bits in a byte. */
-#define BYTE_BITS 8
-/* Number of single byte character. */
-#define SBC_MAX 256
-
-#define COLL_ELEM_LEN_MAX 8
-
-/* The character which represents newline. */
-#define NEWLINE_CHAR '\n'
-#define WIDE_NEWLINE_CHAR L'\n'
-
-/* Rename to standard API for using out of glibc. */
-#ifndef _LIBC
-# define __wctype wctype
-# define __iswctype iswctype
-# define __btowc btowc
-/* This one is defined by string2.h */
-# ifndef __mempcpy
-# define __mempcpy mempcpy
-# endif
-# define __wcrtomb wcrtomb
-# define attribute_hidden
-#endif /* not _LIBC */
-
-#ifdef __GNUC__
-# define __attribute(arg) __attribute__ (arg)
-#else
-# define __attribute(arg)
-#endif
-
-extern const char __re_error_msgid[] attribute_hidden;
-extern const size_t __re_error_msgid_idx[] attribute_hidden;
-
-/* Number of bits in an unsinged int. */
-#define UINT_BITS (sizeof (unsigned int) * BYTE_BITS)
-/* Number of unsigned int in an bit_set. */
-#define BITSET_UINTS ((SBC_MAX + UINT_BITS - 1) / UINT_BITS)
-typedef unsigned int bitset[BITSET_UINTS];
-typedef unsigned int *re_bitset_ptr_t;
-typedef const unsigned int *re_const_bitset_ptr_t;
-
-#define bitset_set(set,i) (set[i / UINT_BITS] |= 1 << i % UINT_BITS)
-#define bitset_clear(set,i) (set[i / UINT_BITS] &= ~(1 << i % UINT_BITS))
-#define bitset_contain(set,i) (set[i / UINT_BITS] & (1 << i % UINT_BITS))
-#define bitset_empty(set) memset (set, 0, sizeof (unsigned int) * BITSET_UINTS)
-#define bitset_set_all(set) \
- memset (set, 255, sizeof (unsigned int) * BITSET_UINTS)
-#define bitset_copy(dest,src) \
- memcpy (dest, src, sizeof (unsigned int) * BITSET_UINTS)
-static inline void bitset_not (bitset set);
-static inline void bitset_merge (bitset dest, const bitset src);
-static inline void bitset_not_merge (bitset dest, const bitset src);
-static inline void bitset_mask (bitset dest, const bitset src);
-
-#define PREV_WORD_CONSTRAINT 0x0001
-#define PREV_NOTWORD_CONSTRAINT 0x0002
-#define NEXT_WORD_CONSTRAINT 0x0004
-#define NEXT_NOTWORD_CONSTRAINT 0x0008
-#define PREV_NEWLINE_CONSTRAINT 0x0010
-#define NEXT_NEWLINE_CONSTRAINT 0x0020
-#define PREV_BEGBUF_CONSTRAINT 0x0040
-#define NEXT_ENDBUF_CONSTRAINT 0x0080
-#define DUMMY_CONSTRAINT 0x0100
-
-typedef enum
-{
- INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
- WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
- WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
- LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
- LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
- BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
- BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
- WORD_DELIM = DUMMY_CONSTRAINT
-} re_context_type;
-
-typedef struct
-{
- int alloc;
- int nelem;
- int *elems;
-} re_node_set;
-
-typedef enum
-{
- NON_TYPE = 0,
-
- /* Node type, These are used by token, node, tree. */
- CHARACTER = 1,
- END_OF_RE = 2,
- SIMPLE_BRACKET = 3,
- OP_BACK_REF = 4,
- OP_PERIOD = 5,
-#ifdef RE_ENABLE_I18N
- COMPLEX_BRACKET = 6,
- OP_UTF8_PERIOD = 7,
-#endif /* RE_ENABLE_I18N */
-
- /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
- when the debugger shows values of this enum type. */
-#define EPSILON_BIT 8
- OP_OPEN_SUBEXP = EPSILON_BIT | 0,
- OP_CLOSE_SUBEXP = EPSILON_BIT | 1,
- OP_ALT = EPSILON_BIT | 2,
- OP_DUP_ASTERISK = EPSILON_BIT | 3,
- OP_DUP_PLUS = EPSILON_BIT | 4,
- OP_DUP_QUESTION = EPSILON_BIT | 5,
- ANCHOR = EPSILON_BIT | 6,
-
- /* Tree type, these are used only by tree. */
- CONCAT = 16,
-
- /* Token type, these are used only by token. */
- OP_OPEN_BRACKET = 17,
- OP_CLOSE_BRACKET,
- OP_CHARSET_RANGE,
- OP_OPEN_DUP_NUM,
- OP_CLOSE_DUP_NUM,
- OP_NON_MATCH_LIST,
- OP_OPEN_COLL_ELEM,
- OP_CLOSE_COLL_ELEM,
- OP_OPEN_EQUIV_CLASS,
- OP_CLOSE_EQUIV_CLASS,
- OP_OPEN_CHAR_CLASS,
- OP_CLOSE_CHAR_CLASS,
- OP_WORD,
- OP_NOTWORD,
- OP_SPACE,
- OP_NOTSPACE,
- BACK_SLASH
-
-} re_token_type_t;
-
-#ifdef RE_ENABLE_I18N
-typedef struct
-{
- /* Multibyte characters. */
- wchar_t *mbchars;
-
- /* Collating symbols. */
-# ifdef _LIBC
- int32_t *coll_syms;
-# endif
-
- /* Equivalence classes. */
-# ifdef _LIBC
- int32_t *equiv_classes;
-# endif
-
- /* Range expressions. */
-# ifdef _LIBC
- uint32_t *range_starts;
- uint32_t *range_ends;
-# else /* not _LIBC */
- wchar_t *range_starts;
- wchar_t *range_ends;
-# endif /* not _LIBC */
-
- /* Character classes. */
- wctype_t *char_classes;
-
- /* If this character set is the non-matching list. */
- unsigned int non_match : 1;
-
- /* # of multibyte characters. */
- int nmbchars;
-
- /* # of collating symbols. */
- int ncoll_syms;
-
- /* # of equivalence classes. */
- int nequiv_classes;
-
- /* # of range expressions. */
- int nranges;
-
- /* # of character classes. */
- int nchar_classes;
-} re_charset_t;
-#endif /* RE_ENABLE_I18N */
-
-typedef struct
-{
- union
- {
- unsigned char c; /* for CHARACTER */
- re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
-#ifdef RE_ENABLE_I18N
- re_charset_t *mbcset; /* for COMPLEX_BRACKET */
-#endif /* RE_ENABLE_I18N */
- int idx; /* for BACK_REF */
- re_context_type ctx_type; /* for ANCHOR */
- } opr;
-#if __GNUC__ >= 2
- re_token_type_t type : 8;
-#else
- re_token_type_t type;
-#endif
- unsigned int constraint : 10; /* context constraint */
- unsigned int duplicated : 1;
- unsigned int opt_subexp : 1;
-#ifdef RE_ENABLE_I18N
- /* These 2 bits can be moved into the union if needed (e.g. if running out
- of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
- unsigned int mb_partial : 1;
-#endif
- unsigned int word_char : 1;
-} re_token_t;
-
-#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT)
-#define ACCEPT_MB_NODE(type) \
- ((type) >= OP_PERIOD && (type) <= OP_UTF8_PERIOD)
-
-struct re_string_t
-{
- /* Indicate the raw buffer which is the original string passed as an
- argument of regexec(), re_search(), etc.. */
- const unsigned char *raw_mbs;
- /* Store the multibyte string. In case of "case insensitive mode" like
- REG_ICASE, upper cases of the string are stored, otherwise MBS points
- the same address that RAW_MBS points. */
- unsigned char *mbs;
-#ifdef RE_ENABLE_I18N
- /* Store the wide character string which is corresponding to MBS. */
- wint_t *wcs;
- int *offsets;
- mbstate_t cur_state;
-#endif
- /* Index in RAW_MBS. Each character mbs[i] corresponds to
- raw_mbs[raw_mbs_idx + i]. */
- int raw_mbs_idx;
- /* The length of the valid characters in the buffers. */
- int valid_len;
- /* The corresponding number of bytes in raw_mbs array. */
- int valid_raw_len;
- /* The length of the buffers MBS and WCS. */
- int bufs_len;
- /* The index in MBS, which is updated by re_string_fetch_byte. */
- int cur_idx;
- /* length of RAW_MBS array. */
- int raw_len;
- /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */
- int len;
- /* End of the buffer may be shorter than its length in the cases such
- as re_match_2, re_search_2. Then, we use STOP for end of the buffer
- instead of LEN. */
- int raw_stop;
- /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */
- int stop;
-
- /* The context of mbs[0]. We store the context independently, since
- the context of mbs[0] may be different from raw_mbs[0], which is
- the beginning of the input string. */
- unsigned int tip_context;
- /* The translation passed as a part of an argument of re_compile_pattern. */
- unsigned RE_TRANSLATE_TYPE trans;
- /* Copy of re_dfa_t's word_char. */
- re_const_bitset_ptr_t word_char;
- /* 1 if REG_ICASE. */
- unsigned char icase;
- unsigned char is_utf8;
- unsigned char map_notascii;
- unsigned char mbs_allocated;
- unsigned char offsets_needed;
- unsigned char newline_anchor;
- unsigned char word_ops_used;
- int mb_cur_max;
-};
-typedef struct re_string_t re_string_t;
-
-
-struct re_dfa_t;
-typedef struct re_dfa_t re_dfa_t;
-
-#ifndef _LIBC
-# ifdef __i386__
-# define internal_function __attribute ((regparm (3), stdcall))
-# else
-# define internal_function
-# endif
-#endif
-
-#ifndef RE_NO_INTERNAL_PROTOTYPES
-static reg_errcode_t re_string_allocate (re_string_t *pstr, const char *str,
- int len, int init_len,
- RE_TRANSLATE_TYPE trans, int icase,
- const re_dfa_t *dfa)
- internal_function;
-static reg_errcode_t re_string_construct (re_string_t *pstr, const char *str,
- int len, RE_TRANSLATE_TYPE trans,
- int icase, const re_dfa_t *dfa)
- internal_function;
-static reg_errcode_t re_string_reconstruct (re_string_t *pstr, int idx,
- int eflags) internal_function;
-static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
- int new_buf_len)
- internal_function;
-# ifdef RE_ENABLE_I18N
-static void build_wcs_buffer (re_string_t *pstr) internal_function;
-static int build_wcs_upper_buffer (re_string_t *pstr) internal_function;
-# endif /* RE_ENABLE_I18N */
-static void build_upper_buffer (re_string_t *pstr) internal_function;
-static void re_string_translate_buffer (re_string_t *pstr) internal_function;
-static void re_string_destruct (re_string_t *pstr) internal_function;
-# ifdef RE_ENABLE_I18N
-static int re_string_elem_size_at (const re_string_t *pstr, int idx)
- internal_function;
-static inline int re_string_char_size_at (const re_string_t *pstr, int idx)
- internal_function;
-static inline wint_t re_string_wchar_at (const re_string_t *pstr, int idx)
- internal_function;
-# endif /* RE_ENABLE_I18N */
-static unsigned int re_string_context_at (const re_string_t *input, int idx,
- int eflags) internal_function;
-static unsigned char re_string_peek_byte_case (const re_string_t *pstr,
- int idx) internal_function;
-static unsigned char re_string_fetch_byte_case (re_string_t *pstr)
- internal_function;
-#endif
-#define re_string_peek_byte(pstr, offset) \
- ((pstr)->mbs[(pstr)->cur_idx + offset])
-#define re_string_fetch_byte(pstr) \
- ((pstr)->mbs[(pstr)->cur_idx++])
-#define re_string_first_byte(pstr, idx) \
- ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF)
-#define re_string_is_single_byte_char(pstr, idx) \
- ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \
- || (pstr)->wcs[(idx) + 1] != WEOF))
-#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx)
-#define re_string_cur_idx(pstr) ((pstr)->cur_idx)
-#define re_string_get_buffer(pstr) ((pstr)->mbs)
-#define re_string_length(pstr) ((pstr)->len)
-#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx])
-#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
-#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
-
-#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
-#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
-#define re_free(p) free (p)
-
-struct bin_tree_t
-{
- struct bin_tree_t *parent;
- struct bin_tree_t *left;
- struct bin_tree_t *right;
-
- /* `node_idx' is the index in dfa->nodes, if `type' == 0.
- Otherwise `type' indicate the type of this node. */
- re_token_type_t type;
- int node_idx;
-
- int first;
- int next;
- re_node_set eclosure;
-};
-typedef struct bin_tree_t bin_tree_t;
-
-#define BIN_TREE_STORAGE_SIZE \
- ((1024 - sizeof (void *)) / sizeof (bin_tree_t))
-
-struct bin_tree_storage_t
-{
- struct bin_tree_storage_t *next;
- bin_tree_t data[BIN_TREE_STORAGE_SIZE];
-};
-typedef struct bin_tree_storage_t bin_tree_storage_t;
-
-#define CONTEXT_WORD 1
-#define CONTEXT_NEWLINE (CONTEXT_WORD << 1)
-#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1)
-#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1)
-
-#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD)
-#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE)
-#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF)
-#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF)
-#define IS_ORDINARY_CONTEXT(c) ((c) == 0)
-
-#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
-#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
-#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_')
-#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
-
-#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
- ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
- || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
- || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\
- || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context)))
-
-#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \
- ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
- || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
- || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \
- || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context)))
-
-struct re_dfastate_t
-{
- unsigned int hash;
- re_node_set nodes;
- re_node_set *entrance_nodes;
- struct re_dfastate_t **trtable;
- struct re_dfastate_t **word_trtable;
- unsigned int context : 4;
- unsigned int halt : 1;
- /* If this state can accept `multi byte'.
- Note that we refer to multibyte characters, and multi character
- collating elements as `multi byte'. */
- unsigned int accept_mb : 1;
- /* If this state has backreference node(s). */
- unsigned int has_backref : 1;
- unsigned int has_constraint : 1;
-};
-typedef struct re_dfastate_t re_dfastate_t;
-
-typedef struct
-{
- /* start <= node < end */
- int start;
- int end;
-} re_subexp_t;
-
-struct re_state_table_entry
-{
- int num;
- int alloc;
- re_dfastate_t **array;
-};
-
-/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */
-
-typedef struct
-{
- int next_idx;
- int alloc;
- re_dfastate_t **array;
-} state_array_t;
-
-/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */
-
-typedef struct
-{
- int node;
- int str_idx; /* The position NODE match at. */
- state_array_t path;
-} re_sub_match_last_t;
-
-/* Store information about the node NODE whose type is OP_OPEN_SUBEXP.
- And information about the node, whose type is OP_CLOSE_SUBEXP,
- corresponding to NODE is stored in LASTS. */
-
-typedef struct
-{
- int str_idx;
- int node;
- int next_last_offset;
- state_array_t *path;
- int alasts; /* Allocation size of LASTS. */
- int nlasts; /* The number of LASTS. */
- re_sub_match_last_t **lasts;
-} re_sub_match_top_t;
-
-struct re_backref_cache_entry
-{
- int node;
- int str_idx;
- int subexp_from;
- int subexp_to;
- int flag;
-};
-
-typedef struct
-{
- /* The string object corresponding to the input string. */
- re_string_t input;
-#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
- re_dfa_t *const dfa;
-#else
- re_dfa_t *dfa;
-#endif
- /* EFLAGS of the argument of regexec. */
- int eflags;
- /* Where the matching ends. */
- int match_last;
- int last_node;
- /* The state log used by the matcher. */
- re_dfastate_t **state_log;
- int state_log_top;
- /* Back reference cache. */
- int nbkref_ents;
- int abkref_ents;
- struct re_backref_cache_entry *bkref_ents;
- int max_mb_elem_len;
- int nsub_tops;
- int asub_tops;
- re_sub_match_top_t **sub_tops;
-} re_match_context_t;
-
-typedef struct
-{
- int cur_bkref;
- int cls_subexp_idx;
-
- re_dfastate_t **sifted_states;
- re_dfastate_t **limited_states;
-
- re_node_set limits;
-
- int last_node;
- int last_str_idx;
- int check_subexp;
-} re_sift_context_t;
-
-struct re_fail_stack_ent_t
-{
- int idx;
- int node;
- regmatch_t *regs;
- re_node_set eps_via_nodes;
-};
-
-struct re_fail_stack_t
-{
- int num;
- int alloc;
- struct re_fail_stack_ent_t *stack;
-};
-
-struct re_dfa_t
-{
- re_subexp_t *subexps;
- re_token_t *nodes;
- int nodes_alloc;
- int nodes_len;
- int *nexts;
- int *org_indices;
- re_node_set *edests;
- re_node_set *eclosures;
- re_node_set *inveclosures;
- struct re_state_table_entry *state_table;
- re_dfastate_t *init_state;
- re_dfastate_t *init_state_word;
- re_dfastate_t *init_state_nl;
- re_dfastate_t *init_state_begbuf;
- bin_tree_t *str_tree;
- bin_tree_storage_t *str_tree_storage;
- re_bitset_ptr_t sb_char;
- int str_tree_storage_idx;
-
- /* number of subexpressions `re_nsub' is in regex_t. */
- int subexps_alloc;
- unsigned int state_hash_mask;
- int states_alloc;
- int init_node;
- int nbackref; /* The number of backreference in this dfa. */
- /* Bitmap expressing which backreference is used. */
- unsigned int used_bkref_map;
- unsigned int has_plural_match : 1;
- /* If this dfa has "multibyte node", which is a backreference or
- a node which can accept multibyte character or multi character
- collating element. */
- unsigned int has_mb_node : 1;
- unsigned int is_utf8 : 1;
- unsigned int map_notascii : 1;
- unsigned int word_ops_used : 1;
- int mb_cur_max;
- bitset word_char;
- reg_syntax_t syntax;
-#ifdef DEBUG
- char* re_str;
-#endif
-};
-
-#ifndef RE_NO_INTERNAL_PROTOTYPES
-static reg_errcode_t re_node_set_alloc (re_node_set *set, int size) internal_function;
-static reg_errcode_t re_node_set_init_1 (re_node_set *set, int elem) internal_function;
-static reg_errcode_t re_node_set_init_2 (re_node_set *set, int elem1,
- int elem2) internal_function;
-#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
-static reg_errcode_t re_node_set_init_copy (re_node_set *dest,
- const re_node_set *src) internal_function;
-static reg_errcode_t re_node_set_add_intersect (re_node_set *dest,
- const re_node_set *src1,
- const re_node_set *src2) internal_function;
-static reg_errcode_t re_node_set_init_union (re_node_set *dest,
- const re_node_set *src1,
- const re_node_set *src2) internal_function;
-static reg_errcode_t re_node_set_merge (re_node_set *dest,
- const re_node_set *src) internal_function;
-static int re_node_set_insert (re_node_set *set, int elem) internal_function;
-static int re_node_set_compare (const re_node_set *set1,
- const re_node_set *set2) internal_function;
-static int re_node_set_contains (const re_node_set *set, int elem) internal_function;
-static void re_node_set_remove_at (re_node_set *set, int idx) internal_function;
-#define re_node_set_remove(set,id) \
- (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1))
-#define re_node_set_empty(p) ((p)->nelem = 0)
-#define re_node_set_free(set) re_free ((set)->elems)
-static int re_dfa_add_node (re_dfa_t *dfa, re_token_t token, int mode) internal_function;
-static re_dfastate_t *re_acquire_state (reg_errcode_t *err, re_dfa_t *dfa,
- const re_node_set *nodes) internal_function;
-static re_dfastate_t *re_acquire_state_context (reg_errcode_t *err,
- re_dfa_t *dfa,
- const re_node_set *nodes,
- unsigned int context) internal_function;
-static void free_state (re_dfastate_t *state) internal_function;
-#endif
-
-
-typedef enum
-{
- SB_CHAR,
- MB_CHAR,
- EQUIV_CLASS,
- COLL_SYM,
- CHAR_CLASS
-} bracket_elem_type;
-
-typedef struct
-{
- bracket_elem_type type;
- union
- {
- unsigned char ch;
- unsigned char *name;
- wchar_t wch;
- } opr;
-} bracket_elem_t;
-
-
-/* Inline functions for bitset operation. */
-static inline void
-bitset_not (set)
- bitset set;
-{
- int bitset_i;
- for (bitset_i = 0; bitset_i < BITSET_UINTS; ++bitset_i)
- set[bitset_i] = ~set[bitset_i];
-}
-
-static inline void
-bitset_merge (dest, src)
- bitset dest;
- const bitset src;
-{
- int bitset_i;
- for (bitset_i = 0; bitset_i < BITSET_UINTS; ++bitset_i)
- dest[bitset_i] |= src[bitset_i];
-}
-
-static inline void
-bitset_not_merge (dest, src)
- bitset dest;
- const bitset src;
-{
- int i;
- for (i = 0; i < BITSET_UINTS; ++i)
- dest[i] |= ~src[i];
-}
-
-static inline void
-bitset_mask (dest, src)
- bitset dest;
- const bitset src;
-{
- int bitset_i;
- for (bitset_i = 0; bitset_i < BITSET_UINTS; ++bitset_i)
- dest[bitset_i] &= src[bitset_i];
-}
-
-#if defined RE_ENABLE_I18N && !defined RE_NO_INTERNAL_PROTOTYPES
-/* Inline functions for re_string. */
-static inline int
-re_string_char_size_at (pstr, idx)
- const re_string_t *pstr;
- int idx;
-{
- int byte_idx;
- if (pstr->mb_cur_max == 1)
- return 1;
- for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx)
- if (pstr->wcs[idx + byte_idx] != WEOF)
- break;
- return byte_idx;
-}
-
-static inline wint_t
-re_string_wchar_at (pstr, idx)
- const re_string_t *pstr;
- int idx;
-{
- if (pstr->mb_cur_max == 1)
- return (wint_t) pstr->mbs[idx];
- return (wint_t) pstr->wcs[idx];
-}
-
-static int
-re_string_elem_size_at (pstr, idx)
- const re_string_t *pstr;
- int idx;
-{
-#ifdef _LIBC
- const unsigned char *p, *extra;
- const int32_t *table, *indirect;
- int32_t tmp;
-# include
- uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
-
- if (nrules != 0)
- {
- table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
- extra = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
- indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
- _NL_COLLATE_INDIRECTMB);
- p = pstr->mbs + idx;
- tmp = findidx (&p);
- return p - pstr->mbs - idx;
- }
- else
-#endif /* _LIBC */
- return 1;
-}
-#endif /* RE_ENABLE_I18N */
-
-#endif /* _REGEX_INTERNAL_H */
diff --git a/lib/regexec.c b/lib/regexec.c
deleted file mode 100644
index 66e0df7..0000000
--- a/lib/regexec.c
+++ /dev/null
@@ -1,4269 +0,0 @@
-/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Isamu Hasegawa .
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
- int n) internal_function;
-static void match_ctx_clean (re_match_context_t *mctx) internal_function;
-static void match_ctx_free (re_match_context_t *cache) internal_function;
-static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, int node,
- int str_idx, int from, int to)
- internal_function;
-static int search_cur_bkref_entry (re_match_context_t *mctx, int str_idx)
- internal_function;
-static void match_ctx_clear_flag (re_match_context_t *mctx) internal_function;
-static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, int node,
- int str_idx) internal_function;
-static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop,
- int node, int str_idx)
- internal_function;
-static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
- re_dfastate_t **limited_sts, int last_node,
- int last_str_idx, int check_subexp)
- internal_function;
-static reg_errcode_t re_search_internal (const regex_t *preg,
- const char *string, int length,
- int start, int range, int stop,
- size_t nmatch, regmatch_t pmatch[],
- int eflags) internal_function;
-static int re_search_2_stub (struct re_pattern_buffer *bufp,
- const char *string1, int length1,
- const char *string2, int length2,
- int start, int range, struct re_registers *regs,
- int stop, int ret_len) internal_function;
-static int re_search_stub (struct re_pattern_buffer *bufp,
- const char *string, int length, int start,
- int range, int stop, struct re_registers *regs,
- int ret_len) internal_function;
-static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
- int nregs, int regs_allocated) internal_function;
-static inline re_dfastate_t *acquire_init_state_context
- (reg_errcode_t *err, const re_match_context_t *mctx, int idx)
- internal_function;
-static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
- internal_function;
-static int check_matching (re_match_context_t *mctx, int fl_longest_match,
- int *p_match_first)
- internal_function;
-static int check_halt_node_context (const re_dfa_t *dfa, int node,
- unsigned int context) internal_function;
-static int check_halt_state_context (const re_match_context_t *mctx,
- const re_dfastate_t *state, int idx)
- internal_function;
-static void update_regs (re_dfa_t *dfa, regmatch_t *pmatch,
- regmatch_t *prev_idx_match, int cur_node,
- int cur_idx, int nmatch) internal_function;
-static int proceed_next_node (const re_match_context_t *mctx,
- int nregs, regmatch_t *regs,
- int *pidx, int node, re_node_set *eps_via_nodes,
- struct re_fail_stack_t *fs) internal_function;
-static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
- int str_idx, int *dests, int nregs,
- regmatch_t *regs,
- re_node_set *eps_via_nodes) internal_function;
-static int pop_fail_stack (struct re_fail_stack_t *fs, int *pidx, int nregs,
- regmatch_t *regs, re_node_set *eps_via_nodes) internal_function;
-static reg_errcode_t set_regs (const regex_t *preg,
- const re_match_context_t *mctx,
- size_t nmatch, regmatch_t *pmatch,
- int fl_backtrack) internal_function;
-static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) internal_function;
-
-#ifdef RE_ENABLE_I18N
-static int sift_states_iter_mb (const re_match_context_t *mctx,
- re_sift_context_t *sctx,
- int node_idx, int str_idx, int max_str_idx) internal_function;
-#endif /* RE_ENABLE_I18N */
-static reg_errcode_t sift_states_backward (re_match_context_t *mctx,
- re_sift_context_t *sctx) internal_function;
-static reg_errcode_t update_cur_sifted_state (re_match_context_t *mctx,
- re_sift_context_t *sctx,
- int str_idx,
- re_node_set *dest_nodes) internal_function;
-static reg_errcode_t add_epsilon_src_nodes (re_dfa_t *dfa,
- re_node_set *dest_nodes,
- const re_node_set *candidates) internal_function;
-static reg_errcode_t sub_epsilon_src_nodes (re_dfa_t *dfa, int node,
- re_node_set *dest_nodes,
- const re_node_set *and_nodes) internal_function;
-static int check_dst_limits (re_match_context_t *mctx, re_node_set *limits,
- int dst_node, int dst_idx, int src_node,
- int src_idx) internal_function;
-static int check_dst_limits_calc_pos (re_match_context_t *mctx,
- int limit, re_node_set *eclosures,
- int subexp_idx, int node, int str_idx) internal_function;
-static reg_errcode_t check_subexp_limits (re_dfa_t *dfa,
- re_node_set *dest_nodes,
- const re_node_set *candidates,
- re_node_set *limits,
- struct re_backref_cache_entry *bkref_ents,
- int str_idx) internal_function;
-static reg_errcode_t sift_states_bkref (re_match_context_t *mctx,
- re_sift_context_t *sctx,
- int str_idx, re_node_set *dest_nodes) internal_function;
-static reg_errcode_t clean_state_log_if_needed (re_match_context_t *mctx,
- int next_state_log_idx) internal_function;
-static reg_errcode_t merge_state_array (re_dfa_t *dfa, re_dfastate_t **dst,
- re_dfastate_t **src, int num) internal_function;
-static re_dfastate_t *find_recover_state (reg_errcode_t *err,
- re_match_context_t *mctx) internal_function;
-static re_dfastate_t *transit_state (reg_errcode_t *err,
- re_match_context_t *mctx,
- re_dfastate_t *state)
- internal_function;
-static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
- re_match_context_t *mctx,
- re_dfastate_t *next_state) internal_function;
-static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
- re_node_set *cur_nodes,
- int str_idx) internal_function;
-#if 0
-static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
- re_match_context_t *mctx,
- re_dfastate_t *pstate) internal_function;
-#endif
-#ifdef RE_ENABLE_I18N
-static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
- re_dfastate_t *pstate) internal_function;
-#endif /* RE_ENABLE_I18N */
-static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
- const re_node_set *nodes) internal_function;
-static reg_errcode_t get_subexp (re_match_context_t *mctx,
- int bkref_node, int bkref_str_idx) internal_function;
-static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
- const re_sub_match_top_t *sub_top,
- re_sub_match_last_t *sub_last,
- int bkref_node, int bkref_str) internal_function;
-static int find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
- int subexp_idx, int type) internal_function;
-static reg_errcode_t check_arrival (re_match_context_t *mctx,
- state_array_t *path, int top_node,
- int top_str, int last_node, int last_str,
- int type) internal_function;
-static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
- int str_idx,
- re_node_set *cur_nodes,
- re_node_set *next_nodes) internal_function;
-static reg_errcode_t check_arrival_expand_ecl (re_dfa_t *dfa,
- re_node_set *cur_nodes,
- int ex_subexp, int type) internal_function;
-static reg_errcode_t check_arrival_expand_ecl_sub (re_dfa_t *dfa,
- re_node_set *dst_nodes,
- int target, int ex_subexp,
- int type) internal_function;
-static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
- re_node_set *cur_nodes, int cur_str,
- int last_str, int subexp_num,
- int type) internal_function;
-static int build_trtable (re_dfa_t *dfa,
- re_dfastate_t *state) internal_function;
-#ifdef RE_ENABLE_I18N
-static int check_node_accept_bytes (re_dfa_t *dfa, int node_idx,
- const re_string_t *input, int idx) internal_function;
-# ifdef _LIBC
-static unsigned int find_collation_sequence_value (const unsigned char *mbs,
- size_t name_len) internal_function;
-# endif /* _LIBC */
-#endif /* RE_ENABLE_I18N */
-static int group_nodes_into_DFAstates (re_dfa_t *dfa,
- const re_dfastate_t *state,
- re_node_set *states_node,
- bitset *states_ch) internal_function;
-static int check_node_accept (const re_match_context_t *mctx,
- const re_token_t *node, int idx) internal_function;
-static reg_errcode_t extend_buffers (re_match_context_t *mctx) internal_function;
-
-/* Entry point for POSIX code. */
-
-/* regexec searches for a given pattern, specified by PREG, in the
- string STRING.
-
- If NMATCH is zero or REG_NOSUB was set in the cflags argument to
- `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
- least NMATCH elements, and we set them to the offsets of the
- corresponding matched substrings.
-
- EFLAGS specifies `execution flags' which affect matching: if
- REG_NOTBOL is set, then ^ does not match at the beginning of the
- string; if REG_NOTEOL is set, then $ does not match at the end.
-
- We return 0 if we find a match and REG_NOMATCH if not. */
-
-int
-regexec (preg, string, nmatch, pmatch, eflags)
- const regex_t *__restrict preg;
- const char *__restrict string;
- size_t nmatch;
- regmatch_t pmatch[];
- int eflags;
-{
- reg_errcode_t err;
- int start, length;
- if (eflags & REG_STARTEND)
- {
- start = pmatch[0].rm_so;
- length = pmatch[0].rm_eo;
- }
- else
- {
- start = 0;
- length = strlen (string);
- }
- if (preg->no_sub)
- err = re_search_internal (preg, string, length, start, length - start,
- length, 0, NULL, eflags);
- else
- err = re_search_internal (preg, string, length, start, length - start,
- length, nmatch, pmatch, eflags);
- return err != REG_NOERROR;
-}
-#ifdef _LIBC
-weak_alias (__regexec, regexec)
-#endif
-
-/* Entry points for GNU code. */
-
-/* re_match, re_search, re_match_2, re_search_2
-
- The former two functions operate on STRING with length LENGTH,
- while the later two operate on concatenation of STRING1 and STRING2
- with lengths LENGTH1 and LENGTH2, respectively.
-
- re_match() matches the compiled pattern in BUFP against the string,
- starting at index START.
-
- re_search() first tries matching at index START, then it tries to match
- starting from index START + 1, and so on. The last start position tried
- is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same
- way as re_match().)
-
- The parameter STOP of re_{match,search}_2 specifies that no match exceeding
- the first STOP characters of the concatenation of the strings should be
- concerned.
-
- If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match
- and all groups is stroed in REGS. (For the "_2" variants, the offsets are
- computed relative to the concatenation, not relative to the individual
- strings.)
-
- On success, re_match* functions return the length of the match, re_search*
- return the position of the start of the match. Return value -1 means no
- match was found and -2 indicates an internal error. */
-
-int
-re_match (bufp, string, length, start, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start;
- struct re_registers *regs;
-{
- return re_search_stub (bufp, string, length, start, 0, length, regs, 1);
-}
-#ifdef _LIBC
-weak_alias (__re_match, re_match)
-#endif
-
-int
-re_search (bufp, string, length, start, range, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start, range;
- struct re_registers *regs;
-{
- return re_search_stub (bufp, string, length, start, range, length, regs, 0);
-}
-#ifdef _LIBC
-weak_alias (__re_search, re_search)
-#endif
-
-int
-re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, stop;
- struct re_registers *regs;
-{
- return re_search_2_stub (bufp, string1, length1, string2, length2,
- start, 0, regs, stop, 1);
-}
-#ifdef _LIBC
-weak_alias (__re_match_2, re_match_2)
-#endif
-
-int
-re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, range, stop;
- struct re_registers *regs;
-{
- return re_search_2_stub (bufp, string1, length1, string2, length2,
- start, range, regs, stop, 0);
-}
-#ifdef _LIBC
-weak_alias (__re_search_2, re_search_2)
-#endif
-
-static int
-re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
- stop, ret_len)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, range, stop, ret_len;
- struct re_registers *regs;
-{
- const char *str;
- int rval;
- int len = length1 + length2;
- int free_str = 0;
-
- if (BE (length1 < 0 || length2 < 0 || stop < 0, 0))
- return -2;
-
- /* Concatenate the strings. */
- if (length2 > 0)
- if (length1 > 0)
- {
- char *s = re_malloc (char, len);
-
- if (BE (s == NULL, 0))
- return -2;
- memcpy (s, string1, length1);
- memcpy (s + length1, string2, length2);
- str = s;
- free_str = 1;
- }
- else
- str = string2;
- else
- str = string1;
-
- rval = re_search_stub (bufp, str, len, start, range, stop, regs,
- ret_len);
- if (free_str)
- re_free ((char *) str);
- return rval;
-}
-
-/* The parameters have the same meaning as those of re_search.
- Additional parameters:
- If RET_LEN is nonzero the length of the match is returned (re_match style);
- otherwise the position of the match is returned. */
-
-static int
-re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start, range, stop, ret_len;
- struct re_registers *regs;
-{
- reg_errcode_t result;
- regmatch_t *pmatch;
- int nregs, rval;
- int eflags = 0;
-
- /* Check for out-of-range. */
- if (BE (start < 0 || start > length, 0))
- return -1;
- if (BE (start + range > length, 0))
- range = length - start;
- else if (BE (start + range < 0, 0))
- range = -start;
-
- eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
- eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
-
- /* Compile fastmap if we haven't yet. */
- if (range > 0 && bufp->fastmap != NULL && !bufp->fastmap_accurate)
- re_compile_fastmap (bufp);
-
- if (BE (bufp->no_sub, 0))
- regs = NULL;
-
- /* We need at least 1 register. */
- if (regs == NULL)
- nregs = 1;
- else if (BE (bufp->regs_allocated == REGS_FIXED &&
- regs->num_regs < bufp->re_nsub + 1, 0))
- {
- nregs = regs->num_regs;
- if (BE (nregs < 1, 0))
- {
- /* Nothing can be copied to regs. */
- regs = NULL;
- nregs = 1;
- }
- }
- else
- nregs = bufp->re_nsub + 1;
- pmatch = re_malloc (regmatch_t, nregs);
- if (BE (pmatch == NULL, 0))
- return -2;
-
- result = re_search_internal (bufp, string, length, start, range, stop,
- nregs, pmatch, eflags);
-
- rval = 0;
-
- /* I hope we needn't fill ther regs with -1's when no match was found. */
- if (result != REG_NOERROR)
- rval = -1;
- else if (regs != NULL)
- {
- /* If caller wants register contents data back, copy them. */
- bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
- bufp->regs_allocated);
- if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0))
- rval = -2;
- }
-
- if (BE (rval == 0, 1))
- {
- if (ret_len)
- {
- assert (pmatch[0].rm_so == start);
- rval = pmatch[0].rm_eo - start;
- }
- else
- rval = pmatch[0].rm_so;
- }
- re_free (pmatch);
- return rval;
-}
-
-static unsigned
-re_copy_regs (regs, pmatch, nregs, regs_allocated)
- struct re_registers *regs;
- regmatch_t *pmatch;
- int nregs, regs_allocated;
-{
- int rval = REGS_REALLOCATE;
- int i;
- int need_regs = nregs + 1;
- /* We need one extra element beyond `num_regs' for the `-1' marker GNU code
- uses. */
-
- /* Have the register data arrays been allocated? */
- if (regs_allocated == REGS_UNALLOCATED)
- { /* No. So allocate them with malloc. */
- regs->start = re_malloc (regoff_t, need_regs);
- regs->end = re_malloc (regoff_t, need_regs);
- if (BE (regs->start == NULL, 0) || BE (regs->end == NULL, 0))
- return REGS_UNALLOCATED;
- regs->num_regs = need_regs;
- }
- else if (regs_allocated == REGS_REALLOCATE)
- { /* Yes. If we need more elements than were already
- allocated, reallocate them. If we need fewer, just
- leave it alone. */
- if (BE (need_regs > regs->num_regs, 0))
- {
- regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
- regoff_t *new_end = re_realloc (regs->end, regoff_t, need_regs);
- if (BE (new_start == NULL, 0) || BE (new_end == NULL, 0))
- return REGS_UNALLOCATED;
- regs->start = new_start;
- regs->end = new_end;
- regs->num_regs = need_regs;
- }
- }
- else
- {
- assert (regs_allocated == REGS_FIXED);
- /* This function may not be called with REGS_FIXED and nregs too big. */
- assert (regs->num_regs >= nregs);
- rval = REGS_FIXED;
- }
-
- /* Copy the regs. */
- for (i = 0; i < nregs; ++i)
- {
- regs->start[i] = pmatch[i].rm_so;
- regs->end[i] = pmatch[i].rm_eo;
- }
- for ( ; i < regs->num_regs; ++i)
- regs->start[i] = regs->end[i] = -1;
-
- return rval;
-}
-
-/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
- ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
- this memory for recording register information. STARTS and ENDS
- must be allocated using the malloc library routine, and must each
- be at least NUM_REGS * sizeof (regoff_t) bytes long.
-
- If NUM_REGS == 0, then subsequent matches should allocate their own
- register data.
-
- Unless this function is called, the first search or match using
- PATTERN_BUFFER will allocate its own register data, without
- freeing the old data. */
-
-void
-re_set_registers (bufp, regs, num_regs, starts, ends)
- struct re_pattern_buffer *bufp;
- struct re_registers *regs;
- unsigned num_regs;
- regoff_t *starts, *ends;
-{
- if (num_regs)
- {
- bufp->regs_allocated = REGS_REALLOCATE;
- regs->num_regs = num_regs;
- regs->start = starts;
- regs->end = ends;
- }
- else
- {
- bufp->regs_allocated = REGS_UNALLOCATED;
- regs->num_regs = 0;
- regs->start = regs->end = (regoff_t *) 0;
- }
-}
-#ifdef _LIBC
-weak_alias (__re_set_registers, re_set_registers)
-#endif
-
-/* Entry points compatible with 4.2 BSD regex library. We don't define
- them unless specifically requested. */
-
-#if defined _REGEX_RE_COMP || defined _LIBC
-int
-# ifdef _LIBC
-weak_function
-# endif
-re_exec (s)
- const char *s;
-{
- return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
-}
-#endif /* _REGEX_RE_COMP */
-
-static re_node_set empty_set;
-
-/* Internal entry point. */
-
-/* Searches for a compiled pattern PREG in the string STRING, whose
- length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same
- mingings with regexec. START, and RANGE have the same meanings
- with re_search.
- Return REG_NOERROR if we find a match, and REG_NOMATCH if not,
- otherwise return the error code.
- Note: We assume front end functions already check ranges.
- (START + RANGE >= 0 && START + RANGE <= LENGTH) */
-
-static reg_errcode_t
-re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch,
- eflags)
- const regex_t *preg;
- const char *string;
- int length, start, range, stop, eflags;
- size_t nmatch;
- regmatch_t pmatch[];
-{
- reg_errcode_t err;
- re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
- int left_lim, right_lim, incr;
- int fl_longest_match, match_first, match_kind, match_last = -1;
- int fast_translate, sb, ch;
-#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
- re_match_context_t mctx = { .dfa = dfa };
-#else
- re_match_context_t mctx;
-#endif
- char *fastmap = (preg->fastmap != NULL && preg->fastmap_accurate
- && range && !preg->can_be_null) ? preg->fastmap : NULL;
- unsigned RE_TRANSLATE_TYPE t = (unsigned RE_TRANSLATE_TYPE) preg->translate;
-
-#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
- memset (&mctx, '\0', sizeof (re_match_context_t));
- mctx.dfa = dfa;
-#endif
-
- /* Check if the DFA haven't been compiled. */
- if (BE (preg->used == 0 || dfa->init_state == NULL
- || dfa->init_state_word == NULL || dfa->init_state_nl == NULL
- || dfa->init_state_begbuf == NULL, 0))
- return REG_NOMATCH;
-
-#ifdef DEBUG
- /* We assume front-end functions already check them. */
- assert (start + range >= 0 && start + range <= length);
-#endif
-
- /* If initial states with non-begbuf contexts have no elements,
- the regex must be anchored. If preg->newline_anchor is set,
- we'll never use init_state_nl, so do not check it. */
- if (dfa->init_state->nodes.nelem == 0
- && dfa->init_state_word->nodes.nelem == 0
- && (dfa->init_state_nl->nodes.nelem == 0
- || !preg->newline_anchor))
- {
- if (start != 0 && start + range != 0)
- return REG_NOMATCH;
- start = range = 0;
- }
-
- re_node_set_init_empty (&empty_set);
-
- /* We must check the longest matching, if nmatch > 0. */
- fl_longest_match = (nmatch != 0 || dfa->nbackref);
-
- err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
- preg->translate, preg->syntax & RE_ICASE, dfa);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- mctx.input.stop = stop;
- mctx.input.raw_stop = stop;
- mctx.input.newline_anchor = preg->newline_anchor;
-
- err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
-
- /* We will log all the DFA states through which the dfa pass,
- if nmatch > 1, or this dfa has "multibyte node", which is a
- back-reference or a node which can accept multibyte character or
- multi character collating element. */
- if (nmatch > 1 || dfa->has_mb_node)
- {
- mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
- if (BE (mctx.state_log == NULL, 0))
- {
- err = REG_ESPACE;
- goto free_return;
- }
- }
- else
- mctx.state_log = NULL;
-
- match_first = start;
- mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
- : CONTEXT_NEWLINE | CONTEXT_BEGBUF;
-
- /* Check incrementally whether of not the input string match. */
- incr = (range < 0) ? -1 : 1;
- left_lim = (range < 0) ? start + range : start;
- right_lim = (range < 0) ? start : start + range;
- sb = dfa->mb_cur_max == 1;
- match_kind =
- (fastmap ? 8 : 0)
- | (sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0)
- | (range >= 0 ? 2 : 0)
- | (t != NULL ? 1 : 0);
-
- for (;; match_first += incr)
- {
- err = REG_NOMATCH;
- if (match_first < left_lim || right_lim < match_first)
- goto free_return;
-
- /* Advance as rapidly as possible through the string, until we
- find a plausible place to start matching. This may be done
- with varying efficiency, so there are various possibilities:
- only the most common of them are specialized to save code.
- We use a switch statement for speed. */
- switch (match_kind)
- {
- case 0: case 1: case 2: case 3:
- case 4: case 5: case 6: case 7:
- /* No fastmap. */
- break;
-
- case 15:
- /* Fastmap with single-byte translation, match forward. */
- while (BE (match_first < right_lim, 1)
- && !fastmap[t[(unsigned char) string[match_first]]])
- ++match_first;
- goto forward_match_found_start_or_reached_end;
-
- case 14:
- /* Fastmap without translation, match forward. */
- while (BE (match_first < right_lim, 1)
- && !fastmap[(unsigned char) string[match_first]])
- ++match_first;
-
- forward_match_found_start_or_reached_end:
- if (BE (match_first == right_lim, 0))
- {
- ch = match_first >= length
- ? 0 : (unsigned char) string[match_first];
- if (!fastmap[t ? t[ch] : ch])
- goto free_return;
- }
- break;
-
- case 12:
- case 13:
- /* Fastmap without multi-byte translation, match backwards. */
- while (match_first >= left_lim)
- {
- ch = match_first >= length
- ? 0 : (unsigned char) string[match_first];
- if (fastmap[t ? t[ch] : ch])
- break;
- --match_first;
- }
- if (match_first < left_lim)
- goto free_return;
- break;
-
- default:
- /* In this case, we can't determine easily the current byte,
- since it might be a component byte of a multibyte
- character. Then we use the constructed buffer instead. */
- do
- {
- /* If MATCH_FIRST is out of the valid range, reconstruct the
- buffers. */
- if (mctx.input.raw_mbs_idx + mctx.input.valid_raw_len <= match_first
- || match_first < mctx.input.raw_mbs_idx)
- {
- err = re_string_reconstruct (&mctx.input, match_first,
- eflags);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- }
- /* If MATCH_FIRST is out of the buffer, leave it as '\0'.
- Note that MATCH_FIRST must not be smaller than 0. */
- ch = ((match_first >= length) ? 0
- : re_string_byte_at (&mctx.input,
- match_first - mctx.input.raw_mbs_idx));
- if (fastmap[ch])
- break;
- match_first += incr;
- }
- while (match_first >= left_lim && match_first <= right_lim);
- if (!fastmap[ch])
- {
- err = REG_NOMATCH;
- goto free_return;
- }
- break;
- }
-
- /* Reconstruct the buffers so that the matcher can assume that
- the matching starts from the beginning of the buffer. */
- err = re_string_reconstruct (&mctx.input, match_first, eflags);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
-
-#ifdef RE_ENABLE_I18N
- /* Don't consider this char as a possible match start if it part,
- yet isn't the head, of a multibyte character. */
- if (!sb && !re_string_first_byte (&mctx.input, 0))
- continue;
-#endif
-
- /* It seems to be appropriate one, then use the matcher. */
- /* We assume that the matching starts from 0. */
- mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
- match_last = check_matching (&mctx, fl_longest_match,
- range >= 0 ? &match_first : NULL);
- if (match_last != -1)
- {
- if (BE (match_last == -2, 0))
- {
- err = REG_ESPACE;
- goto free_return;
- }
- else
- {
- mctx.match_last = match_last;
- if ((!preg->no_sub && nmatch > 1) || dfa->nbackref)
- {
- re_dfastate_t *pstate = mctx.state_log[match_last];
- mctx.last_node = check_halt_state_context (&mctx, pstate,
- match_last);
- }
- if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match)
- || dfa->nbackref)
- {
- err = prune_impossible_nodes (&mctx);
- if (err == REG_NOERROR)
- break;
- if (BE (err != REG_NOMATCH, 0))
- goto free_return;
- match_last = -1;
- }
- else
- break; /* We found a match. */
- }
- }
-
- match_ctx_clean (&mctx);
- }
-
-#ifdef DEBUG
- assert (match_last != -1);
- assert (err == REG_NOERROR);
-#endif
-
- /* Set pmatch[] if we need. */
- if (nmatch > 0)
- {
- int reg_idx;
-
- /* Initialize registers. */
- for (reg_idx = 1; reg_idx < nmatch; ++reg_idx)
- pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1;
-
- /* Set the points where matching start/end. */
- pmatch[0].rm_so = 0;
- pmatch[0].rm_eo = mctx.match_last;
-
- if (!preg->no_sub && nmatch > 1)
- {
- err = set_regs (preg, &mctx, nmatch, pmatch,
- dfa->has_plural_match && dfa->nbackref > 0);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- }
-
- /* At last, add the offset to the each registers, since we slided
- the buffers so that we could assume that the matching starts
- from 0. */
- for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
- if (pmatch[reg_idx].rm_so != -1)
- {
-#ifdef RE_ENABLE_I18N
- if (BE (mctx.input.offsets_needed != 0, 0))
- {
- if (pmatch[reg_idx].rm_so == mctx.input.valid_len)
- pmatch[reg_idx].rm_so += mctx.input.valid_raw_len - mctx.input.valid_len;
- else
- pmatch[reg_idx].rm_so = mctx.input.offsets[pmatch[reg_idx].rm_so];
- if (pmatch[reg_idx].rm_eo == mctx.input.valid_len)
- pmatch[reg_idx].rm_eo += mctx.input.valid_raw_len - mctx.input.valid_len;
- else
- pmatch[reg_idx].rm_eo = mctx.input.offsets[pmatch[reg_idx].rm_eo];
- }
-#else
- assert (mctx.input.offsets_needed == 0);
-#endif
- pmatch[reg_idx].rm_so += match_first;
- pmatch[reg_idx].rm_eo += match_first;
- }
- }
-
- free_return:
- re_free (mctx.state_log);
- if (dfa->nbackref)
- match_ctx_free (&mctx);
- re_string_destruct (&mctx.input);
- return err;
-}
-
-static reg_errcode_t
-prune_impossible_nodes (mctx)
- re_match_context_t *mctx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- int halt_node, match_last;
- reg_errcode_t ret;
- re_dfastate_t **sifted_states;
- re_dfastate_t **lim_states = NULL;
- re_sift_context_t sctx;
-#ifdef DEBUG
- assert (mctx->state_log != NULL);
-#endif
- match_last = mctx->match_last;
- halt_node = mctx->last_node;
- sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
- if (BE (sifted_states == NULL, 0))
- {
- ret = REG_ESPACE;
- goto free_return;
- }
- if (dfa->nbackref)
- {
- lim_states = re_malloc (re_dfastate_t *, match_last + 1);
- if (BE (lim_states == NULL, 0))
- {
- ret = REG_ESPACE;
- goto free_return;
- }
- while (1)
- {
- memset (lim_states, '\0',
- sizeof (re_dfastate_t *) * (match_last + 1));
- match_ctx_clear_flag (mctx);
- sift_ctx_init (&sctx, sifted_states, lim_states, halt_node,
- match_last, 0);
- ret = sift_states_backward (mctx, &sctx);
- re_node_set_free (&sctx.limits);
- if (BE (ret != REG_NOERROR, 0))
- goto free_return;
- if (sifted_states[0] != NULL || lim_states[0] != NULL)
- break;
- do
- {
- --match_last;
- if (match_last < 0)
- {
- ret = REG_NOMATCH;
- goto free_return;
- }
- } while (mctx->state_log[match_last] == NULL
- || !mctx->state_log[match_last]->halt);
- halt_node = check_halt_state_context (mctx,
- mctx->state_log[match_last],
- match_last);
- }
- ret = merge_state_array (dfa, sifted_states, lim_states,
- match_last + 1);
- re_free (lim_states);
- lim_states = NULL;
- if (BE (ret != REG_NOERROR, 0))
- goto free_return;
- }
- else
- {
- sift_ctx_init (&sctx, sifted_states, lim_states, halt_node,
- match_last, 0);
- ret = sift_states_backward (mctx, &sctx);
- re_node_set_free (&sctx.limits);
- if (BE (ret != REG_NOERROR, 0))
- goto free_return;
- }
- re_free (mctx->state_log);
- mctx->state_log = sifted_states;
- sifted_states = NULL;
- mctx->last_node = halt_node;
- mctx->match_last = match_last;
- ret = REG_NOERROR;
- free_return:
- re_free (sifted_states);
- re_free (lim_states);
- return ret;
-}
-
-/* Acquire an initial state and return it.
- We must select appropriate initial state depending on the context,
- since initial states may have constraints like "\<", "^", etc.. */
-
-static inline re_dfastate_t *
-acquire_init_state_context (err, mctx, idx)
- reg_errcode_t *err;
- const re_match_context_t *mctx;
- int idx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- if (dfa->init_state->has_constraint)
- {
- unsigned int context;
- context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags);
- if (IS_WORD_CONTEXT (context))
- return dfa->init_state_word;
- else if (IS_ORDINARY_CONTEXT (context))
- return dfa->init_state;
- else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context))
- return dfa->init_state_begbuf;
- else if (IS_NEWLINE_CONTEXT (context))
- return dfa->init_state_nl;
- else if (IS_BEGBUF_CONTEXT (context))
- {
- /* It is relatively rare case, then calculate on demand. */
- return re_acquire_state_context (err, dfa,
- dfa->init_state->entrance_nodes,
- context);
- }
- else
- /* Must not happen? */
- return dfa->init_state;
- }
- else
- return dfa->init_state;
-}
-
-/* Check whether the regular expression match input string INPUT or not,
- and return the index where the matching end, return -1 if not match,
- or return -2 in case of an error.
- FL_LONGEST_MATCH means we want the POSIX longest matching.
- If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
- next place where we may want to try matching.
- Note that the matcher assume that the maching starts from the current
- index of the buffer. */
-
-static int
-check_matching (mctx, fl_longest_match, p_match_first)
- re_match_context_t *mctx;
- int fl_longest_match;
- int *p_match_first;
-{
- re_dfa_t *const dfa = mctx->dfa;
- reg_errcode_t err;
- int match = 0;
- int match_last = -1;
- int cur_str_idx = re_string_cur_idx (&mctx->input);
- re_dfastate_t *cur_state;
- int at_init_state = p_match_first != NULL;
- int next_start_idx = cur_str_idx;
-
- err = REG_NOERROR;
- cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
- /* An initial state must not be NULL (invalid). */
- if (BE (cur_state == NULL, 0))
- {
- assert (err == REG_ESPACE);
- return -2;
- }
-
- if (mctx->state_log != NULL)
- {
- mctx->state_log[cur_str_idx] = cur_state;
-
- /* Check OP_OPEN_SUBEXP in the initial state in case that we use them
- later. E.g. Processing back references. */
- if (BE (dfa->nbackref, 0))
- {
- at_init_state = 0;
- err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
- if (BE (err != REG_NOERROR, 0))
- return err;
-
- if (cur_state->has_backref)
- {
- err = transit_state_bkref (mctx, &cur_state->nodes);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- }
- }
-
- /* If the RE accepts NULL string. */
- if (BE (cur_state->halt, 0))
- {
- if (!cur_state->has_constraint
- || check_halt_state_context (mctx, cur_state, cur_str_idx))
- {
- if (!fl_longest_match)
- return cur_str_idx;
- else
- {
- match_last = cur_str_idx;
- match = 1;
- }
- }
- }
-
- while (!re_string_eoi (&mctx->input))
- {
- re_dfastate_t *old_state = cur_state;
- int next_char_idx = re_string_cur_idx (&mctx->input) + 1;
-
- if (BE (next_char_idx >= mctx->input.bufs_len, 0)
- || (BE (next_char_idx >= mctx->input.valid_len, 0)
- && mctx->input.valid_len < mctx->input.len))
- {
- err = extend_buffers (mctx);
- if (BE (err != REG_NOERROR, 0))
- {
- assert (err == REG_ESPACE);
- return -2;
- }
- }
-
- cur_state = transit_state (&err, mctx, cur_state);
- if (mctx->state_log != NULL)
- cur_state = merge_state_with_log (&err, mctx, cur_state);
-
- if (cur_state == NULL)
- {
- /* Reached the invalid state or an error. Try to recover a valid
- state using the state log, if available and if we have not
- already found a valid (even if not the longest) match. */
- if (BE (err != REG_NOERROR, 0))
- return -2;
-
- if (mctx->state_log == NULL
- || (match && !fl_longest_match)
- || (cur_state = find_recover_state (&err, mctx)) == NULL)
- break;
- }
-
- if (BE (at_init_state, 0))
- {
- if (old_state == cur_state)
- next_start_idx = next_char_idx;
- else
- at_init_state = 0;
- }
-
- if (cur_state->halt)
- {
- /* Reached a halt state.
- Check the halt state can satisfy the current context. */
- if (!cur_state->has_constraint
- || check_halt_state_context (mctx, cur_state,
- re_string_cur_idx (&mctx->input)))
- {
- /* We found an appropriate halt state. */
- match_last = re_string_cur_idx (&mctx->input);
- match = 1;
-
- /* We found a match, do not modify match_first below. */
- p_match_first = NULL;
- if (!fl_longest_match)
- break;
- }
- }
- }
-
- if (p_match_first)
- *p_match_first += next_start_idx;
-
- return match_last;
-}
-
-/* Check NODE match the current context. */
-
-static int check_halt_node_context (dfa, node, context)
- const re_dfa_t *dfa;
- int node;
- unsigned int context;
-{
- re_token_type_t type = dfa->nodes[node].type;
- unsigned int constraint = dfa->nodes[node].constraint;
- if (type != END_OF_RE)
- return 0;
- if (!constraint)
- return 1;
- if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context))
- return 0;
- return 1;
-}
-
-/* Check the halt state STATE match the current context.
- Return 0 if not match, if the node, STATE has, is a halt node and
- match the context, return the node. */
-
-static int
-check_halt_state_context (mctx, state, idx)
- const re_match_context_t *mctx;
- const re_dfastate_t *state;
- int idx;
-{
- int i;
- unsigned int context;
-#ifdef DEBUG
- assert (state->halt);
-#endif
- context = re_string_context_at (&mctx->input, idx, mctx->eflags);
- for (i = 0; i < state->nodes.nelem; ++i)
- if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
- return state->nodes.elems[i];
- return 0;
-}
-
-/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA
- corresponding to the DFA).
- Return the destination node, and update EPS_VIA_NODES, return -1 in case
- of errors. */
-
-static int
-proceed_next_node (mctx, nregs, regs, pidx, node, eps_via_nodes, fs)
- const re_match_context_t *mctx;
- regmatch_t *regs;
- int nregs, *pidx, node;
- re_node_set *eps_via_nodes;
- struct re_fail_stack_t *fs;
-{
- re_dfa_t *const dfa = mctx->dfa;
- int i, err, dest_node;
- dest_node = -1;
- if (IS_EPSILON_NODE (dfa->nodes[node].type))
- {
- re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
- int ndest, dest_nodes[2];
- err = re_node_set_insert (eps_via_nodes, node);
- if (BE (err < 0, 0))
- return -2;
- /* Pick up valid destinations. */
- for (ndest = 0, i = 0; i < dfa->edests[node].nelem; ++i)
- {
- int candidate = dfa->edests[node].elems[i];
- if (!re_node_set_contains (cur_nodes, candidate))
- continue;
- dest_nodes[0] = (ndest == 0) ? candidate : dest_nodes[0];
- dest_nodes[1] = (ndest == 1) ? candidate : dest_nodes[1];
- ++ndest;
- }
- if (ndest <= 1)
- return ndest == 0 ? -1 : (ndest == 1 ? dest_nodes[0] : 0);
- /* In order to avoid infinite loop like "(a*)*". */
- if (re_node_set_contains (eps_via_nodes, dest_nodes[0]))
- return dest_nodes[1];
- if (fs != NULL
- && push_fail_stack (fs, *pidx, dest_nodes, nregs, regs,
- eps_via_nodes))
- return -2;
- return dest_nodes[0];
- }
- else
- {
- int naccepted = 0;
- re_token_type_t type = dfa->nodes[node].type;
-
-#ifdef RE_ENABLE_I18N
- if (ACCEPT_MB_NODE (type))
- naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
- else
-#endif /* RE_ENABLE_I18N */
- if (type == OP_BACK_REF)
- {
- int subexp_idx = dfa->nodes[node].opr.idx;
- naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
- if (fs != NULL)
- {
- if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1)
- return -1;
- else if (naccepted)
- {
- char *buf = (char *) re_string_get_buffer (&mctx->input);
- if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
- naccepted) != 0)
- return -1;
- }
- }
-
- if (naccepted == 0)
- {
- err = re_node_set_insert (eps_via_nodes, node);
- if (BE (err < 0, 0))
- return -2;
- dest_node = dfa->edests[node].elems[0];
- if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
- dest_node))
- return dest_node;
- }
- }
-
- if (naccepted != 0
- || check_node_accept (mctx, dfa->nodes + node, *pidx))
- {
- dest_node = dfa->nexts[node];
- *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted;
- if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL
- || !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
- dest_node)))
- return -1;
- re_node_set_empty (eps_via_nodes);
- return dest_node;
- }
- }
- return -1;
-}
-
-static reg_errcode_t
-push_fail_stack (fs, str_idx, dests, nregs, regs, eps_via_nodes)
- struct re_fail_stack_t *fs;
- int str_idx, *dests, nregs;
- regmatch_t *regs;
- re_node_set *eps_via_nodes;
-{
- reg_errcode_t err;
- int num = fs->num++;
- if (fs->num == fs->alloc)
- {
- struct re_fail_stack_ent_t *new_array;
- new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t)
- * fs->alloc * 2));
- if (new_array == NULL)
- return REG_ESPACE;
- fs->alloc *= 2;
- fs->stack = new_array;
- }
- fs->stack[num].idx = str_idx;
- fs->stack[num].node = dests[1];
- fs->stack[num].regs = re_malloc (regmatch_t, nregs);
- if (fs->stack[num].regs == NULL)
- return REG_ESPACE;
- memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
- err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
- return err;
-}
-
-static int
-pop_fail_stack (fs, pidx, nregs, regs, eps_via_nodes)
- struct re_fail_stack_t *fs;
- int *pidx, nregs;
- regmatch_t *regs;
- re_node_set *eps_via_nodes;
-{
- int num = --fs->num;
- assert (num >= 0);
- *pidx = fs->stack[num].idx;
- memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
- re_node_set_free (eps_via_nodes);
- re_free (fs->stack[num].regs);
- *eps_via_nodes = fs->stack[num].eps_via_nodes;
- return fs->stack[num].node;
-}
-
-/* Set the positions where the subexpressions are starts/ends to registers
- PMATCH.
- Note: We assume that pmatch[0] is already set, and
- pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */
-
-static reg_errcode_t
-set_regs (preg, mctx, nmatch, pmatch, fl_backtrack)
- const regex_t *preg;
- const re_match_context_t *mctx;
- size_t nmatch;
- regmatch_t *pmatch;
- int fl_backtrack;
-{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
- int idx, cur_node, real_nmatch;
- re_node_set eps_via_nodes;
- struct re_fail_stack_t *fs;
- struct re_fail_stack_t fs_body = { 0, 2, NULL };
- regmatch_t *prev_idx_match;
-
-#ifdef DEBUG
- assert (nmatch > 1);
- assert (mctx->state_log != NULL);
-#endif
- if (fl_backtrack)
- {
- fs = &fs_body;
- fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc);
- if (fs->stack == NULL)
- return REG_ESPACE;
- }
- else
- fs = NULL;
-
- cur_node = dfa->init_node;
- real_nmatch = (nmatch <= preg->re_nsub) ? nmatch : preg->re_nsub + 1;
- re_node_set_init_empty (&eps_via_nodes);
-
- prev_idx_match = (regmatch_t *) alloca (sizeof (regmatch_t) * real_nmatch);
- memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * real_nmatch);
-
- for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
- {
- update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, real_nmatch);
-
- if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
- {
- int reg_idx;
- if (fs)
- {
- for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
- if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
- break;
- if (reg_idx == nmatch)
- {
- re_node_set_free (&eps_via_nodes);
- return free_fail_stack_return (fs);
- }
- cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
- &eps_via_nodes);
- }
- else
- {
- re_node_set_free (&eps_via_nodes);
- return REG_NOERROR;
- }
- }
-
- /* Proceed to next node. */
- cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
- &eps_via_nodes, fs);
-
- if (BE (cur_node < 0, 0))
- {
- if (BE (cur_node == -2, 0))
- {
- re_node_set_free (&eps_via_nodes);
- free_fail_stack_return (fs);
- return REG_ESPACE;
- }
- if (fs)
- cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
- &eps_via_nodes);
- else
- {
- re_node_set_free (&eps_via_nodes);
- return REG_NOMATCH;
- }
- }
- }
- re_node_set_free (&eps_via_nodes);
- return free_fail_stack_return (fs);
-}
-
-static reg_errcode_t
-free_fail_stack_return (fs)
- struct re_fail_stack_t *fs;
-{
- if (fs)
- {
- int fs_idx;
- for (fs_idx = 0; fs_idx < fs->num; ++fs_idx)
- {
- re_node_set_free (&fs->stack[fs_idx].eps_via_nodes);
- re_free (fs->stack[fs_idx].regs);
- }
- re_free (fs->stack);
- }
- return REG_NOERROR;
-}
-
-static void
-update_regs (dfa, pmatch, prev_idx_match, cur_node, cur_idx, nmatch)
- re_dfa_t *dfa;
- regmatch_t *pmatch, *prev_idx_match;
- int cur_node, cur_idx, nmatch;
-{
- int type = dfa->nodes[cur_node].type;
- if (type == OP_OPEN_SUBEXP)
- {
- int reg_num = dfa->nodes[cur_node].opr.idx + 1;
-
- /* We are at the first node of this sub expression. */
- if (reg_num < nmatch)
- {
- pmatch[reg_num].rm_so = cur_idx;
- pmatch[reg_num].rm_eo = -1;
- }
- }
- else if (type == OP_CLOSE_SUBEXP)
- {
- int reg_num = dfa->nodes[cur_node].opr.idx + 1;
- if (reg_num < nmatch)
- {
- /* We are at the last node of this sub expression. */
- if (pmatch[reg_num].rm_so < cur_idx)
- {
- pmatch[reg_num].rm_eo = cur_idx;
- /* This is a non-empty match or we are not inside an optional
- subexpression. Accept this right away. */
- memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
- }
- else
- {
- if (dfa->nodes[cur_node].opt_subexp
- && prev_idx_match[reg_num].rm_so != -1)
- /* We transited through an empty match for an optional
- subexpression, like (a?)*, and this is not the subexp's
- first match. Copy back the old content of the registers
- so that matches of an inner subexpression are undone as
- well, like in ((a?))*. */
- memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch);
- else
- /* We completed a subexpression, but it may be part of
- an optional one, so do not update PREV_IDX_MATCH. */
- pmatch[reg_num].rm_eo = cur_idx;
- }
- }
- }
-}
-
-/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0
- and sift the nodes in each states according to the following rules.
- Updated state_log will be wrote to STATE_LOG.
-
- Rules: We throw away the Node `a' in the STATE_LOG[STR_IDX] if...
- 1. When STR_IDX == MATCH_LAST(the last index in the state_log):
- If `a' isn't the LAST_NODE and `a' can't epsilon transit to
- the LAST_NODE, we throw away the node `a'.
- 2. When 0 <= STR_IDX < MATCH_LAST and `a' accepts
- string `s' and transit to `b':
- i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw
- away the node `a'.
- ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is
- thrown away, we throw away the node `a'.
- 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b':
- i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the
- node `a'.
- ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away,
- we throw away the node `a'. */
-
-#define STATE_NODE_CONTAINS(state,node) \
- ((state) != NULL && re_node_set_contains (&(state)->nodes, node))
-
-static reg_errcode_t
-sift_states_backward (mctx, sctx)
- re_match_context_t *mctx;
- re_sift_context_t *sctx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- reg_errcode_t err;
- int null_cnt = 0;
- int str_idx = sctx->last_str_idx;
- re_node_set cur_dest;
- re_node_set *cur_src; /* Points the state_log[str_idx]->nodes */
-
-#ifdef DEBUG
- assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
-#endif
- cur_src = &mctx->state_log[str_idx]->nodes;
-
- /* Build sifted state_log[str_idx]. It has the nodes which can epsilon
- transit to the last_node and the last_node itself. */
- err = re_node_set_init_1 (&cur_dest, sctx->last_node);
- if (BE (err != REG_NOERROR, 0))
- return err;
- err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
-
- /* Then check each states in the state_log. */
- while (str_idx > 0)
- {
- int i, ret;
- /* Update counters. */
- null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0;
- if (null_cnt > mctx->max_mb_elem_len)
- {
- memset (sctx->sifted_states, '\0',
- sizeof (re_dfastate_t *) * str_idx);
- re_node_set_free (&cur_dest);
- return REG_NOERROR;
- }
- re_node_set_empty (&cur_dest);
- --str_idx;
- cur_src = ((mctx->state_log[str_idx] == NULL) ? &empty_set
- : &mctx->state_log[str_idx]->nodes);
-
- /* Then build the next sifted state.
- We build the next sifted state on `cur_dest', and update
- `sifted_states[str_idx]' with `cur_dest'.
- Note:
- `cur_dest' is the sifted state from `state_log[str_idx + 1]'.
- `cur_src' points the node_set of the old `state_log[str_idx]'. */
- for (i = 0; i < cur_src->nelem; i++)
- {
- int prev_node = cur_src->elems[i];
- int naccepted = 0;
- re_token_type_t type = dfa->nodes[prev_node].type;
-
- if (IS_EPSILON_NODE (type))
- continue;
-#ifdef RE_ENABLE_I18N
- /* If the node may accept `multi byte'. */
- if (ACCEPT_MB_NODE (type))
- naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
- str_idx, sctx->last_str_idx);
-
-#endif /* RE_ENABLE_I18N */
- /* We don't check backreferences here.
- See update_cur_sifted_state(). */
-
- if (!naccepted
- && check_node_accept (mctx, dfa->nodes + prev_node, str_idx)
- && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1],
- dfa->nexts[prev_node]))
- naccepted = 1;
-
- if (naccepted == 0)
- continue;
-
- if (sctx->limits.nelem)
- {
- int to_idx = str_idx + naccepted;
- if (check_dst_limits (mctx, &sctx->limits,
- dfa->nexts[prev_node], to_idx,
- prev_node, str_idx))
- continue;
- }
- ret = re_node_set_insert (&cur_dest, prev_node);
- if (BE (ret == -1, 0))
- {
- err = REG_ESPACE;
- goto free_return;
- }
- }
-
- /* Add all the nodes which satisfy the following conditions:
- - It can epsilon transit to a node in CUR_DEST.
- - It is in CUR_SRC.
- And update state_log. */
- err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- }
- err = REG_NOERROR;
- free_return:
- re_node_set_free (&cur_dest);
- return err;
-}
-
-/* Helper functions. */
-
-static reg_errcode_t
-clean_state_log_if_needed (mctx, next_state_log_idx)
- re_match_context_t *mctx;
- int next_state_log_idx;
-{
- int top = mctx->state_log_top;
-
- if (next_state_log_idx >= mctx->input.bufs_len
- || (next_state_log_idx >= mctx->input.valid_len
- && mctx->input.valid_len < mctx->input.len))
- {
- reg_errcode_t err;
- err = extend_buffers (mctx);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
-
- if (top < next_state_log_idx)
- {
- memset (mctx->state_log + top + 1, '\0',
- sizeof (re_dfastate_t *) * (next_state_log_idx - top));
- mctx->state_log_top = next_state_log_idx;
- }
- return REG_NOERROR;
-}
-
-static reg_errcode_t
-merge_state_array (dfa, dst, src, num)
- re_dfa_t *dfa;
- re_dfastate_t **dst;
- re_dfastate_t **src;
- int num;
-{
- int st_idx;
- reg_errcode_t err;
- for (st_idx = 0; st_idx < num; ++st_idx)
- {
- if (dst[st_idx] == NULL)
- dst[st_idx] = src[st_idx];
- else if (src[st_idx] != NULL)
- {
- re_node_set merged_set;
- err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
- &src[st_idx]->nodes);
- if (BE (err != REG_NOERROR, 0))
- return err;
- dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
- re_node_set_free (&merged_set);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- }
- return REG_NOERROR;
-}
-
-static reg_errcode_t
-update_cur_sifted_state (mctx, sctx, str_idx, dest_nodes)
- re_match_context_t *mctx;
- re_sift_context_t *sctx;
- int str_idx;
- re_node_set *dest_nodes;
-{
- re_dfa_t *const dfa = mctx->dfa;
- reg_errcode_t err;
- const re_node_set *candidates;
- candidates = ((mctx->state_log[str_idx] == NULL) ? &empty_set
- : &mctx->state_log[str_idx]->nodes);
-
- /* At first, add the nodes which can epsilon transit to a node in
- DEST_NODE. */
- if (dest_nodes->nelem)
- {
- err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
-
- /* Then, check the limitations in the current sift_context. */
- if (dest_nodes->nelem && sctx->limits.nelem)
- {
- err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
- mctx->bkref_ents, str_idx);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
-
- /* Update state_log. */
- sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
- if (BE (sctx->sifted_states[str_idx] == NULL && err != REG_NOERROR, 0))
- return err;
-
- if ((mctx->state_log[str_idx] != NULL
- && mctx->state_log[str_idx]->has_backref))
- {
- err = sift_states_bkref (mctx, sctx, str_idx, dest_nodes);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- return REG_NOERROR;
-}
-
-static reg_errcode_t
-add_epsilon_src_nodes (dfa, dest_nodes, candidates)
- re_dfa_t *dfa;
- re_node_set *dest_nodes;
- const re_node_set *candidates;
-{
- reg_errcode_t err;
- int src_idx;
- re_node_set src_copy;
-
- err = re_node_set_init_copy (&src_copy, dest_nodes);
- if (BE (err != REG_NOERROR, 0))
- return err;
- for (src_idx = 0; src_idx < src_copy.nelem; ++src_idx)
- {
- err = re_node_set_add_intersect (dest_nodes, candidates,
- dfa->inveclosures
- + src_copy.elems[src_idx]);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&src_copy);
- return err;
- }
- }
- re_node_set_free (&src_copy);
- return REG_NOERROR;
-}
-
-static reg_errcode_t
-sub_epsilon_src_nodes (dfa, node, dest_nodes, candidates)
- re_dfa_t *dfa;
- int node;
- re_node_set *dest_nodes;
- const re_node_set *candidates;
-{
- int ecl_idx;
- reg_errcode_t err;
- re_node_set *inv_eclosure = dfa->inveclosures + node;
- re_node_set except_nodes;
- re_node_set_init_empty (&except_nodes);
- for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
- {
- int cur_node = inv_eclosure->elems[ecl_idx];
- if (cur_node == node)
- continue;
- if (IS_EPSILON_NODE (dfa->nodes[cur_node].type))
- {
- int edst1 = dfa->edests[cur_node].elems[0];
- int edst2 = ((dfa->edests[cur_node].nelem > 1)
- ? dfa->edests[cur_node].elems[1] : -1);
- if ((!re_node_set_contains (inv_eclosure, edst1)
- && re_node_set_contains (dest_nodes, edst1))
- || (edst2 > 0
- && !re_node_set_contains (inv_eclosure, edst2)
- && re_node_set_contains (dest_nodes, edst2)))
- {
- err = re_node_set_add_intersect (&except_nodes, candidates,
- dfa->inveclosures + cur_node);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&except_nodes);
- return err;
- }
- }
- }
- }
- for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
- {
- int cur_node = inv_eclosure->elems[ecl_idx];
- if (!re_node_set_contains (&except_nodes, cur_node))
- {
- int idx = re_node_set_contains (dest_nodes, cur_node) - 1;
- re_node_set_remove_at (dest_nodes, idx);
- }
- }
- re_node_set_free (&except_nodes);
- return REG_NOERROR;
-}
-
-static int
-check_dst_limits (mctx, limits, dst_node, dst_idx, src_node, src_idx)
- re_match_context_t *mctx;
- re_node_set *limits;
- int dst_node, dst_idx, src_node, src_idx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- int lim_idx, src_pos, dst_pos;
-
- for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
- {
- int subexp_idx;
- struct re_backref_cache_entry *ent;
- ent = mctx->bkref_ents + limits->elems[lim_idx];
- subexp_idx = dfa->nodes[ent->node].opr.idx - 1;
-
- dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
- dfa->eclosures + dst_node,
- subexp_idx, dst_node, dst_idx);
- src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
- dfa->eclosures + src_node,
- subexp_idx, src_node, src_idx);
-
- /* In case of:
- ( )
- ( )
- ( ) */
- if (src_pos == dst_pos)
- continue; /* This is unrelated limitation. */
- else
- return 1;
- }
- return 0;
-}
-
-static int
-check_dst_limits_calc_pos (mctx, limit, eclosures, subexp_idx, from_node,
- str_idx)
- re_match_context_t *mctx;
- re_node_set *eclosures;
- int limit, subexp_idx, from_node, str_idx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
- int node_idx;
-
- /* If we are outside the range of the subexpression, return -1 or 1. */
- if (str_idx < lim->subexp_from)
- return -1;
-
- if (lim->subexp_to < str_idx)
- return 1;
-
- /* If we are within the subexpression, return 0. */
- if (str_idx != lim->subexp_from && str_idx != lim->subexp_to)
- return 0;
-
- /* Else, we are on the boundary: examine the nodes on the epsilon
- closure. */
- for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx)
- {
- int node = eclosures->elems[node_idx];
- switch (dfa->nodes[node].type)
- {
- case OP_BACK_REF:
- {
- int bi = search_cur_bkref_entry (mctx, str_idx);
- for (; bi < mctx->nbkref_ents; ++bi)
- {
- struct re_backref_cache_entry *ent = mctx->bkref_ents + bi;
- int dst, cpos;
-
- /* If this backreference goes beyond the point we're
- examining, don't go any further. */
- if (ent->str_idx > str_idx)
- break;
-
- if (ent->node != node || ent->subexp_from != ent->subexp_to)
- continue;
-
- /* Recurse trying to reach the OP_OPEN_SUBEXP and
- OP_CLOSE_SUBEXP cases below. But, if the
- destination node is the same node as the source
- node, don't recurse because it would cause an
- infinite loop: a regex that exhibits this behavior
- is ()\1*\1* */
- dst = dfa->edests[node].elems[0];
- if (dst == from_node)
- {
- if (str_idx == lim->subexp_from)
- return -1;
- else /* if (str_idx == lim->subexp_to) */
- return 0;
- }
-
- cpos = check_dst_limits_calc_pos (mctx, limit,
- dfa->eclosures + dst,
- subexp_idx, dst,
- str_idx);
-
- if (cpos == -1 && str_idx == lim->subexp_from)
- return -1;
-
- if (cpos == 0 /* && str_idx == lim->lim->subexp_to */)
- return 0;
- }
- break;
- }
-
- case OP_OPEN_SUBEXP:
- if (str_idx == lim->subexp_from && subexp_idx == dfa->nodes[node].opr.idx)
- return -1;
- break;
-
- case OP_CLOSE_SUBEXP:
- if (str_idx == lim->subexp_to && subexp_idx == dfa->nodes[node].opr.idx)
- return 0;
- break;
-
- default:
- break;
- }
- }
-
- if (str_idx == lim->subexp_to)
- return 1;
- else
- return 0;
-}
-
-/* Check the limitations of sub expressions LIMITS, and remove the nodes
- which are against limitations from DEST_NODES. */
-
-static reg_errcode_t
-check_subexp_limits (dfa, dest_nodes, candidates, limits, bkref_ents, str_idx)
- re_dfa_t *dfa;
- re_node_set *dest_nodes;
- const re_node_set *candidates;
- re_node_set *limits;
- struct re_backref_cache_entry *bkref_ents;
- int str_idx;
-{
- reg_errcode_t err;
- int node_idx, lim_idx;
-
- for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
- {
- int subexp_idx;
- struct re_backref_cache_entry *ent;
- ent = bkref_ents + limits->elems[lim_idx];
-
- if (str_idx <= ent->subexp_from || ent->str_idx < str_idx)
- continue; /* This is unrelated limitation. */
-
- subexp_idx = dfa->nodes[ent->node].opr.idx - 1;
- if (ent->subexp_to == str_idx)
- {
- int ops_node = -1;
- int cls_node = -1;
- for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
- {
- int node = dest_nodes->elems[node_idx];
- re_token_type_t type = dfa->nodes[node].type;
- if (type == OP_OPEN_SUBEXP
- && subexp_idx == dfa->nodes[node].opr.idx)
- ops_node = node;
- else if (type == OP_CLOSE_SUBEXP
- && subexp_idx == dfa->nodes[node].opr.idx)
- cls_node = node;
- }
-
- /* Check the limitation of the open subexpression. */
- /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */
- if (ops_node >= 0)
- {
- err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
- candidates);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
-
- /* Check the limitation of the close subexpression. */
- if (cls_node >= 0)
- for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
- {
- int node = dest_nodes->elems[node_idx];
- if (!re_node_set_contains (dfa->inveclosures + node,
- cls_node)
- && !re_node_set_contains (dfa->eclosures + node,
- cls_node))
- {
- /* It is against this limitation.
- Remove it form the current sifted state. */
- err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
- candidates);
- if (BE (err != REG_NOERROR, 0))
- return err;
- --node_idx;
- }
- }
- }
- else /* (ent->subexp_to != str_idx) */
- {
- for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
- {
- int node = dest_nodes->elems[node_idx];
- re_token_type_t type = dfa->nodes[node].type;
- if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP)
- {
- if (subexp_idx != dfa->nodes[node].opr.idx)
- continue;
- if ((type == OP_CLOSE_SUBEXP && ent->subexp_to != str_idx)
- || (type == OP_OPEN_SUBEXP))
- {
- /* It is against this limitation.
- Remove it form the current sifted state. */
- err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
- candidates);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- }
- }
- }
- }
- return REG_NOERROR;
-}
-
-static reg_errcode_t
-sift_states_bkref (mctx, sctx, str_idx, dest_nodes)
- re_match_context_t *mctx;
- re_sift_context_t *sctx;
- int str_idx;
- re_node_set *dest_nodes;
-{
- re_dfa_t *const dfa = mctx->dfa;
- reg_errcode_t err;
- int node_idx, node;
- re_sift_context_t local_sctx;
- const re_node_set *candidates;
- candidates = ((mctx->state_log[str_idx] == NULL) ? &empty_set
- : &mctx->state_log[str_idx]->nodes);
- local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */
-
- for (node_idx = 0; node_idx < candidates->nelem; ++node_idx)
- {
- int cur_bkref_idx = re_string_cur_idx (&mctx->input);
- re_token_type_t type;
- node = candidates->elems[node_idx];
- type = dfa->nodes[node].type;
- if (node == sctx->cur_bkref && str_idx == cur_bkref_idx)
- continue;
- /* Avoid infinite loop for the REs like "()\1+". */
- if (node == sctx->last_node && str_idx == sctx->last_str_idx)
- continue;
- if (type == OP_BACK_REF)
- {
- int enabled_idx = search_cur_bkref_entry (mctx, str_idx);
- for (; enabled_idx < mctx->nbkref_ents; ++enabled_idx)
- {
- int disabled_idx, subexp_len, to_idx, dst_node;
- struct re_backref_cache_entry *entry;
- entry = mctx->bkref_ents + enabled_idx;
- if (entry->str_idx > str_idx)
- break;
- if (entry->node != node)
- continue;
- subexp_len = entry->subexp_to - entry->subexp_from;
- to_idx = str_idx + subexp_len;
- dst_node = (subexp_len ? dfa->nexts[node]
- : dfa->edests[node].elems[0]);
-
- if (to_idx > sctx->last_str_idx
- || sctx->sifted_states[to_idx] == NULL
- || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx],
- dst_node)
- || check_dst_limits (mctx, &sctx->limits, node,
- str_idx, dst_node, to_idx))
- continue;
- {
- re_dfastate_t *cur_state;
- entry->flag = 0;
- for (disabled_idx = enabled_idx + 1;
- disabled_idx < mctx->nbkref_ents; ++disabled_idx)
- {
- struct re_backref_cache_entry *entry2;
- entry2 = mctx->bkref_ents + disabled_idx;
- if (entry2->str_idx > str_idx)
- break;
- entry2->flag = (entry2->node == node) ? 1 : entry2->flag;
- }
-
- if (local_sctx.sifted_states == NULL)
- {
- local_sctx = *sctx;
- err = re_node_set_init_copy (&local_sctx.limits,
- &sctx->limits);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- }
- local_sctx.last_node = node;
- local_sctx.last_str_idx = str_idx;
- err = re_node_set_insert (&local_sctx.limits, enabled_idx);
- if (BE (err < 0, 0))
- {
- err = REG_ESPACE;
- goto free_return;
- }
- cur_state = local_sctx.sifted_states[str_idx];
- err = sift_states_backward (mctx, &local_sctx);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- if (sctx->limited_states != NULL)
- {
- err = merge_state_array (dfa, sctx->limited_states,
- local_sctx.sifted_states,
- str_idx + 1);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- }
- local_sctx.sifted_states[str_idx] = cur_state;
- re_node_set_remove (&local_sctx.limits, enabled_idx);
- /* We must not use the variable entry here, since
- mctx->bkref_ents might be realloced. */
- mctx->bkref_ents[enabled_idx].flag = 1;
- }
- }
- enabled_idx = search_cur_bkref_entry (mctx, str_idx);
- for (; enabled_idx < mctx->nbkref_ents; ++enabled_idx)
- {
- struct re_backref_cache_entry *entry;
- entry = mctx->bkref_ents + enabled_idx;
- if (entry->str_idx > str_idx)
- break;
- if (entry->node == node)
- entry->flag = 0;
- }
- }
- }
- err = REG_NOERROR;
- free_return:
- if (local_sctx.sifted_states != NULL)
- {
- re_node_set_free (&local_sctx.limits);
- }
-
- return err;
-}
-
-
-#ifdef RE_ENABLE_I18N
-static int
-sift_states_iter_mb (mctx, sctx, node_idx, str_idx, max_str_idx)
- const re_match_context_t *mctx;
- re_sift_context_t *sctx;
- int node_idx, str_idx, max_str_idx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- int naccepted;
- /* Check the node can accept `multi byte'. */
- naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
- if (naccepted > 0 && str_idx + naccepted <= max_str_idx &&
- !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
- dfa->nexts[node_idx]))
- /* The node can't accept the `multi byte', or the
- destination was already thrown away, then the node
- could't accept the current input `multi byte'. */
- naccepted = 0;
- /* Otherwise, it is sure that the node could accept
- `naccepted' bytes input. */
- return naccepted;
-}
-#endif /* RE_ENABLE_I18N */
-
-
-/* Functions for state transition. */
-
-/* Return the next state to which the current state STATE will transit by
- accepting the current input byte, and update STATE_LOG if necessary.
- If STATE can accept a multibyte char/collating element/back reference
- update the destination of STATE_LOG. */
-
-static re_dfastate_t *
-transit_state (err, mctx, state)
- reg_errcode_t *err;
- re_match_context_t *mctx;
- re_dfastate_t *state;
-{
- re_dfastate_t **trtable, *next_state;
- unsigned char ch;
-
-#ifdef RE_ENABLE_I18N
- /* If the current state can accept multibyte. */
- if (BE (state->accept_mb, 0))
- {
- *err = transit_state_mb (mctx, state);
- if (BE (*err != REG_NOERROR, 0))
- return NULL;
- }
-#endif /* RE_ENABLE_I18N */
-
- /* Then decide the next state with the single byte. */
- if (1)
- {
- /* Use transition table. Sorry for the goto, but we really need
- to squeeze every single instruction here. */
- ch = re_string_fetch_byte (&mctx->input);
-
- retry:
- trtable = state->trtable;
- if (BE (trtable != NULL, 1))
- return trtable[ch];
-
- trtable = state->word_trtable;
- if (BE (trtable != NULL, 1))
- {
- unsigned int context;
- context = re_string_context_at (&mctx->input,
- re_string_cur_idx (&mctx->input) - 1,
- mctx->eflags);
- if (IS_WORD_CONTEXT (context))
- return trtable[ch + SBC_MAX];
- else
- return trtable[ch];
- }
-
- if (!build_trtable (mctx->dfa, state))
- {
- *err = REG_ESPACE;
- return NULL;
- }
- goto retry;
- }
-#if 0
- else
- /* don't use transition table */
- return transit_state_sb (err, mctx, state);
-#endif
-}
-
-/* Update the state_log if we need. */
-re_dfastate_t *
-merge_state_with_log (err, mctx, next_state)
- reg_errcode_t *err;
- re_match_context_t *mctx;
- re_dfastate_t *next_state;
-{
- re_dfa_t *const dfa = mctx->dfa;
- int cur_idx = re_string_cur_idx (&mctx->input);
- if (cur_idx > mctx->state_log_top)
- {
- mctx->state_log[cur_idx] = next_state;
- mctx->state_log_top = cur_idx;
- }
- else if (mctx->state_log[cur_idx] == 0)
- {
- mctx->state_log[cur_idx] = next_state;
- }
- else
- {
- re_dfastate_t *pstate;
- unsigned int context;
- re_node_set next_nodes, *log_nodes, *table_nodes = NULL;
- /* If (state_log[cur_idx] != 0), it implies that cur_idx is
- the destination of a multibyte char/collating element/
- back reference. Then the next state is the union set of
- these destinations and the results of the transition table. */
- pstate = mctx->state_log[cur_idx];
- log_nodes = pstate->entrance_nodes;
- if (next_state != NULL)
- {
- table_nodes = next_state->entrance_nodes;
- *err = re_node_set_init_union (&next_nodes, table_nodes,
- log_nodes);
- if (BE (*err != REG_NOERROR, 0))
- return;
- }
- else
- next_nodes = *log_nodes;
-
- /* Note: We already add the nodes of the initial state,
- then we don't need to add them here. */
-
- context = re_string_context_at (&mctx->input,
- re_string_cur_idx (&mctx->input) - 1,
- mctx->eflags);
- next_state = mctx->state_log[cur_idx]
- = re_acquire_state_context (err, dfa, &next_nodes, context);
-
- /* We don't need to check errors here, since the return value of
- this function is next_state and ERR is already set. */
-
- if (table_nodes != NULL)
- re_node_set_free (&next_nodes);
- }
-
- if (BE (dfa->nbackref, 0) && next_state != NULL)
- {
- /* Check OP_OPEN_SUBEXP in the current state in case that we use them
- later. We must check them here, since the back references in the
- next state might use them. */
- *err = check_subexp_matching_top (mctx, &next_state->nodes,
- cur_idx);
- if (BE (*err != REG_NOERROR, 0))
- return NULL;
-
- /* If the next state has back references. */
- if (next_state->has_backref)
- {
- *err = transit_state_bkref (mctx, &next_state->nodes);
- if (BE (*err != REG_NOERROR, 0))
- return NULL;
- next_state = mctx->state_log[cur_idx];
- }
- }
-
- return next_state;
-}
-
-/* Skip bytes in the input that correspond to part of a
- multi-byte match, then look in the log for a state
- from which to restart matching. */
-re_dfastate_t *
-find_recover_state (err, mctx)
- reg_errcode_t *err;
- re_match_context_t *mctx;
-{
- re_dfastate_t *cur_state = NULL;
- do
- {
- int max = mctx->state_log_top;
- int cur_str_idx = re_string_cur_idx (&mctx->input);
-
- do
- {
- if (++cur_str_idx > max)
- return NULL;
- re_string_skip_bytes (&mctx->input, 1);
- }
- while (mctx->state_log[cur_str_idx] == NULL);
-
- cur_state = merge_state_with_log (err, mctx, NULL);
- }
- while (err == REG_NOERROR && cur_state == NULL);
- return cur_state;
-}
-
-/* Helper functions for transit_state. */
-
-/* From the node set CUR_NODES, pick up the nodes whose types are
- OP_OPEN_SUBEXP and which have corresponding back references in the regular
- expression. And register them to use them later for evaluating the
- correspoding back references. */
-
-static reg_errcode_t
-check_subexp_matching_top (mctx, cur_nodes, str_idx)
- re_match_context_t *mctx;
- re_node_set *cur_nodes;
- int str_idx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- int node_idx;
- reg_errcode_t err;
-
- /* TODO: This isn't efficient.
- Because there might be more than one nodes whose types are
- OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
- nodes.
- E.g. RE: (a){2} */
- for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx)
- {
- int node = cur_nodes->elems[node_idx];
- if (dfa->nodes[node].type == OP_OPEN_SUBEXP
- && dfa->nodes[node].opr.idx < (8 * sizeof (dfa->used_bkref_map))
- && dfa->used_bkref_map & (1 << dfa->nodes[node].opr.idx))
- {
- err = match_ctx_add_subtop (mctx, node, str_idx);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- }
- return REG_NOERROR;
-}
-
-#if 0
-/* Return the next state to which the current state STATE will transit by
- accepting the current input byte. */
-
-static re_dfastate_t *
-transit_state_sb (err, mctx, state)
- reg_errcode_t *err;
- re_match_context_t *mctx;
- re_dfastate_t *state;
-{
- re_dfa_t *const dfa = mctx->dfa;
- re_node_set next_nodes;
- re_dfastate_t *next_state;
- int node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input);
- unsigned int context;
-
- *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
- if (BE (*err != REG_NOERROR, 0))
- return NULL;
- for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
- {
- int cur_node = state->nodes.elems[node_cnt];
- if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx))
- {
- *err = re_node_set_merge (&next_nodes,
- dfa->eclosures + dfa->nexts[cur_node]);
- if (BE (*err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return NULL;
- }
- }
- }
- context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags);
- next_state = re_acquire_state_context (err, dfa, &next_nodes, context);
- /* We don't need to check errors here, since the return value of
- this function is next_state and ERR is already set. */
-
- re_node_set_free (&next_nodes);
- re_string_skip_bytes (&mctx->input, 1);
- return next_state;
-}
-#endif
-
-#ifdef RE_ENABLE_I18N
-static reg_errcode_t
-transit_state_mb (mctx, pstate)
- re_match_context_t *mctx;
- re_dfastate_t *pstate;
-{
- re_dfa_t *const dfa = mctx->dfa;
- reg_errcode_t err;
- int i;
-
- for (i = 0; i < pstate->nodes.nelem; ++i)
- {
- re_node_set dest_nodes, *new_nodes;
- int cur_node_idx = pstate->nodes.elems[i];
- int naccepted = 0, dest_idx;
- unsigned int context;
- re_dfastate_t *dest_state;
-
- if (dfa->nodes[cur_node_idx].constraint)
- {
- context = re_string_context_at (&mctx->input,
- re_string_cur_idx (&mctx->input),
- mctx->eflags);
- if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint,
- context))
- continue;
- }
-
- /* How many bytes the node can accept? */
- if (ACCEPT_MB_NODE (dfa->nodes[cur_node_idx].type))
- naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input,
- re_string_cur_idx (&mctx->input));
- if (naccepted == 0)
- continue;
-
- /* The node can accepts `naccepted' bytes. */
- dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
- mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
- : mctx->max_mb_elem_len);
- err = clean_state_log_if_needed (mctx, dest_idx);
- if (BE (err != REG_NOERROR, 0))
- return err;
-#ifdef DEBUG
- assert (dfa->nexts[cur_node_idx] != -1);
-#endif
- /* `cur_node_idx' may point the entity of the OP_CONTEXT_NODE,
- then we use pstate->nodes.elems[i] instead. */
- new_nodes = dfa->eclosures + dfa->nexts[pstate->nodes.elems[i]];
-
- dest_state = mctx->state_log[dest_idx];
- if (dest_state == NULL)
- dest_nodes = *new_nodes;
- else
- {
- err = re_node_set_init_union (&dest_nodes,
- dest_state->entrance_nodes, new_nodes);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- context = re_string_context_at (&mctx->input, dest_idx - 1, mctx->eflags);
- mctx->state_log[dest_idx]
- = re_acquire_state_context (&err, dfa, &dest_nodes, context);
- if (dest_state != NULL)
- re_node_set_free (&dest_nodes);
- if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0))
- return err;
- }
- return REG_NOERROR;
-}
-#endif /* RE_ENABLE_I18N */
-
-static reg_errcode_t
-transit_state_bkref (mctx, nodes)
- re_match_context_t *mctx;
- const re_node_set *nodes;
-{
- re_dfa_t *const dfa = mctx->dfa;
- reg_errcode_t err;
- int i;
- int cur_str_idx = re_string_cur_idx (&mctx->input);
-
- for (i = 0; i < nodes->nelem; ++i)
- {
- int dest_str_idx, prev_nelem, bkc_idx;
- int node_idx = nodes->elems[i];
- unsigned int context;
- const re_token_t *node = dfa->nodes + node_idx;
- re_node_set *new_dest_nodes;
-
- /* Check whether `node' is a backreference or not. */
- if (node->type != OP_BACK_REF)
- continue;
-
- if (node->constraint)
- {
- context = re_string_context_at (&mctx->input, cur_str_idx,
- mctx->eflags);
- if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
- continue;
- }
-
- /* `node' is a backreference.
- Check the substring which the substring matched. */
- bkc_idx = mctx->nbkref_ents;
- err = get_subexp (mctx, node_idx, cur_str_idx);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
-
- /* And add the epsilon closures (which is `new_dest_nodes') of
- the backreference to appropriate state_log. */
-#ifdef DEBUG
- assert (dfa->nexts[node_idx] != -1);
-#endif
- for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
- {
- int subexp_len;
- re_dfastate_t *dest_state;
- struct re_backref_cache_entry *bkref_ent;
- bkref_ent = mctx->bkref_ents + bkc_idx;
- if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx)
- continue;
- subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from;
- new_dest_nodes = (subexp_len == 0
- ? dfa->eclosures + dfa->edests[node_idx].elems[0]
- : dfa->eclosures + dfa->nexts[node_idx]);
- dest_str_idx = (cur_str_idx + bkref_ent->subexp_to
- - bkref_ent->subexp_from);
- context = re_string_context_at (&mctx->input, dest_str_idx - 1,
- mctx->eflags);
- dest_state = mctx->state_log[dest_str_idx];
- prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0
- : mctx->state_log[cur_str_idx]->nodes.nelem);
- /* Add `new_dest_node' to state_log. */
- if (dest_state == NULL)
- {
- mctx->state_log[dest_str_idx]
- = re_acquire_state_context (&err, dfa, new_dest_nodes,
- context);
- if (BE (mctx->state_log[dest_str_idx] == NULL
- && err != REG_NOERROR, 0))
- goto free_return;
- }
- else
- {
- re_node_set dest_nodes;
- err = re_node_set_init_union (&dest_nodes,
- dest_state->entrance_nodes,
- new_dest_nodes);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&dest_nodes);
- goto free_return;
- }
- mctx->state_log[dest_str_idx]
- = re_acquire_state_context (&err, dfa, &dest_nodes, context);
- re_node_set_free (&dest_nodes);
- if (BE (mctx->state_log[dest_str_idx] == NULL
- && err != REG_NOERROR, 0))
- goto free_return;
- }
- /* We need to check recursively if the backreference can epsilon
- transit. */
- if (subexp_len == 0
- && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem)
- {
- err = check_subexp_matching_top (mctx, new_dest_nodes,
- cur_str_idx);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- err = transit_state_bkref (mctx, new_dest_nodes);
- if (BE (err != REG_NOERROR, 0))
- goto free_return;
- }
- }
- }
- err = REG_NOERROR;
- free_return:
- return err;
-}
-
-/* Enumerate all the candidates which the backreference BKREF_NODE can match
- at BKREF_STR_IDX, and register them by match_ctx_add_entry().
- Note that we might collect inappropriate candidates here.
- However, the cost of checking them strictly here is too high, then we
- delay these checking for prune_impossible_nodes(). */
-
-static reg_errcode_t
-get_subexp (mctx, bkref_node, bkref_str_idx)
- re_match_context_t *mctx;
- int bkref_node, bkref_str_idx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- int subexp_num, sub_top_idx;
- const char *buf = (const char *) re_string_get_buffer (&mctx->input);
- /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */
- int cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
- for (; cache_idx < mctx->nbkref_ents; ++cache_idx)
- {
- const struct re_backref_cache_entry *entry
- = &mctx->bkref_ents[cache_idx];
- if (entry->str_idx > bkref_str_idx)
- break;
- if (entry->node == bkref_node)
- return REG_NOERROR; /* We already checked it. */
- }
- subexp_num = dfa->nodes[bkref_node].opr.idx - 1;
-
- /* For each sub expression */
- for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
- {
- reg_errcode_t err;
- re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx];
- re_sub_match_last_t *sub_last;
- int sub_last_idx, sl_str, bkref_str_off;
-
- if (dfa->nodes[sub_top->node].opr.idx != subexp_num)
- continue; /* It isn't related. */
-
- sl_str = sub_top->str_idx;
- bkref_str_off = bkref_str_idx;
- /* At first, check the last node of sub expressions we already
- evaluated. */
- for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx)
- {
- int sl_str_diff;
- sub_last = sub_top->lasts[sub_last_idx];
- sl_str_diff = sub_last->str_idx - sl_str;
- /* The matched string by the sub expression match with the substring
- at the back reference? */
- if (sl_str_diff > 0)
- {
- if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0))
- {
- /* Not enough chars for a successful match. */
- if (bkref_str_off + sl_str_diff > mctx->input.len)
- break;
-
- err = clean_state_log_if_needed (mctx,
- bkref_str_off
- + sl_str_diff);
- if (BE (err != REG_NOERROR, 0))
- return err;
- buf = (const char *) re_string_get_buffer (&mctx->input);
- }
- if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0)
- break; /* We don't need to search this sub expression any more. */
- }
- bkref_str_off += sl_str_diff;
- sl_str += sl_str_diff;
- err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
- bkref_str_idx);
-
- /* Reload buf, since the preceding call might have reallocated
- the buffer. */
- buf = (const char *) re_string_get_buffer (&mctx->input);
-
- if (err == REG_NOMATCH)
- continue;
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
-
- if (sub_last_idx < sub_top->nlasts)
- continue;
- if (sub_last_idx > 0)
- ++sl_str;
- /* Then, search for the other last nodes of the sub expression. */
- for (; sl_str <= bkref_str_idx; ++sl_str)
- {
- int cls_node, sl_str_off;
- const re_node_set *nodes;
- sl_str_off = sl_str - sub_top->str_idx;
- /* The matched string by the sub expression match with the substring
- at the back reference? */
- if (sl_str_off > 0)
- {
- if (BE (bkref_str_off >= mctx->input.valid_len, 0))
- {
- /* If we are at the end of the input, we cannot match. */
- if (bkref_str_off >= mctx->input.len)
- break;
-
- err = extend_buffers (mctx);
- if (BE (err != REG_NOERROR, 0))
- return err;
-
- buf = (const char *) re_string_get_buffer (&mctx->input);
- }
- if (buf [bkref_str_off++] != buf[sl_str - 1])
- break; /* We don't need to search this sub expression
- any more. */
- }
- if (mctx->state_log[sl_str] == NULL)
- continue;
- /* Does this state have a ')' of the sub expression? */
- nodes = &mctx->state_log[sl_str]->nodes;
- cls_node = find_subexp_node (dfa, nodes, subexp_num, OP_CLOSE_SUBEXP);
- if (cls_node == -1)
- continue; /* No. */
- if (sub_top->path == NULL)
- {
- sub_top->path = calloc (sizeof (state_array_t),
- sl_str - sub_top->str_idx + 1);
- if (sub_top->path == NULL)
- return REG_ESPACE;
- }
- /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node
- in the current context? */
- err = check_arrival (mctx, sub_top->path, sub_top->node,
- sub_top->str_idx, cls_node, sl_str, OP_CLOSE_SUBEXP);
- if (err == REG_NOMATCH)
- continue;
- if (BE (err != REG_NOERROR, 0))
- return err;
- sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
- if (BE (sub_last == NULL, 0))
- return REG_ESPACE;
- err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
- bkref_str_idx);
- if (err == REG_NOMATCH)
- continue;
- }
- }
- return REG_NOERROR;
-}
-
-/* Helper functions for get_subexp(). */
-
-/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR.
- If it can arrive, register the sub expression expressed with SUB_TOP
- and SUB_LAST. */
-
-static reg_errcode_t
-get_subexp_sub (mctx, sub_top, sub_last, bkref_node, bkref_str)
- re_match_context_t *mctx;
- const re_sub_match_top_t *sub_top;
- re_sub_match_last_t *sub_last;
- int bkref_node, bkref_str;
-{
- reg_errcode_t err;
- int to_idx;
- /* Can the subexpression arrive the back reference? */
- err = check_arrival (mctx, &sub_last->path, sub_last->node,
- sub_last->str_idx, bkref_node, bkref_str, OP_OPEN_SUBEXP);
- if (err != REG_NOERROR)
- return err;
- err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
- sub_last->str_idx);
- if (BE (err != REG_NOERROR, 0))
- return err;
- to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
- return clean_state_log_if_needed (mctx, to_idx);
-}
-
-/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX.
- Search '(' if FL_OPEN, or search ')' otherwise.
- TODO: This function isn't efficient...
- Because there might be more than one nodes whose types are
- OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
- nodes.
- E.g. RE: (a){2} */
-
-static int
-find_subexp_node (dfa, nodes, subexp_idx, type)
- const re_dfa_t *dfa;
- const re_node_set *nodes;
- int subexp_idx, type;
-{
- int cls_idx;
- for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx)
- {
- int cls_node = nodes->elems[cls_idx];
- const re_token_t *node = dfa->nodes + cls_node;
- if (node->type == type
- && node->opr.idx == subexp_idx)
- return cls_node;
- }
- return -1;
-}
-
-/* Check whether the node TOP_NODE at TOP_STR can arrive to the node
- LAST_NODE at LAST_STR. We record the path onto PATH since it will be
- heavily reused.
- Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */
-
-static reg_errcode_t
-check_arrival (mctx, path, top_node, top_str, last_node, last_str,
- type)
- re_match_context_t *mctx;
- state_array_t *path;
- int top_node, top_str, last_node, last_str, type;
-{
- re_dfa_t *const dfa = mctx->dfa;
- reg_errcode_t err;
- int subexp_num, backup_cur_idx, str_idx, null_cnt;
- re_dfastate_t *cur_state = NULL;
- re_node_set *cur_nodes, next_nodes;
- re_dfastate_t **backup_state_log;
- unsigned int context;
-
- subexp_num = dfa->nodes[top_node].opr.idx;
- /* Extend the buffer if we need. */
- if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0))
- {
- re_dfastate_t **new_array;
- int old_alloc = path->alloc;
- path->alloc += last_str + mctx->max_mb_elem_len + 1;
- new_array = re_realloc (path->array, re_dfastate_t *, path->alloc);
- if (new_array == NULL)
- {
- path->alloc = old_alloc;
- return REG_ESPACE;
- }
- path->array = new_array;
- memset (new_array + old_alloc, '\0',
- sizeof (re_dfastate_t *) * (path->alloc - old_alloc));
- }
-
- str_idx = path->next_idx == 0 ? top_str : path->next_idx;
-
- /* Temporary modify MCTX. */
- backup_state_log = mctx->state_log;
- backup_cur_idx = mctx->input.cur_idx;
- mctx->state_log = path->array;
- mctx->input.cur_idx = str_idx;
-
- /* Setup initial node set. */
- context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
- if (str_idx == top_str)
- {
- err = re_node_set_init_1 (&next_nodes, top_node);
- if (BE (err != REG_NOERROR, 0))
- return err;
- err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return err;
- }
- }
- else
- {
- cur_state = mctx->state_log[str_idx];
- if (cur_state && cur_state->has_backref)
- {
- err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
- if (BE ( err != REG_NOERROR, 0))
- return err;
- }
- else
- re_node_set_init_empty (&next_nodes);
- }
- if (str_idx == top_str || (cur_state && cur_state->has_backref))
- {
- if (next_nodes.nelem)
- {
- err = expand_bkref_cache (mctx, &next_nodes, str_idx, last_str,
- subexp_num, type);
- if (BE ( err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return err;
- }
- }
- cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
- if (BE (cur_state == NULL && err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return err;
- }
- mctx->state_log[str_idx] = cur_state;
- }
-
- for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;)
- {
- re_node_set_empty (&next_nodes);
- if (mctx->state_log[str_idx + 1])
- {
- err = re_node_set_merge (&next_nodes,
- &mctx->state_log[str_idx + 1]->nodes);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return err;
- }
- }
- if (cur_state)
- {
- err = check_arrival_add_next_nodes (mctx, str_idx,
- &cur_state->nodes, &next_nodes);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return err;
- }
- }
- ++str_idx;
- if (next_nodes.nelem)
- {
- err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return err;
- }
- err = expand_bkref_cache (mctx, &next_nodes, str_idx, last_str,
- subexp_num, type);
- if (BE ( err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return err;
- }
- }
- context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
- cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
- if (BE (cur_state == NULL && err != REG_NOERROR, 0))
- {
- re_node_set_free (&next_nodes);
- return err;
- }
- mctx->state_log[str_idx] = cur_state;
- null_cnt = cur_state == NULL ? null_cnt + 1 : 0;
- }
- re_node_set_free (&next_nodes);
- cur_nodes = (mctx->state_log[last_str] == NULL ? NULL
- : &mctx->state_log[last_str]->nodes);
- path->next_idx = str_idx;
-
- /* Fix MCTX. */
- mctx->state_log = backup_state_log;
- mctx->input.cur_idx = backup_cur_idx;
-
- /* Then check the current node set has the node LAST_NODE. */
- if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node))
- return REG_NOERROR;
-
- return REG_NOMATCH;
-}
-
-/* Helper functions for check_arrival. */
-
-/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them
- to NEXT_NODES.
- TODO: This function is similar to the functions transit_state*(),
- however this function has many additional works.
- Can't we unify them? */
-
-static reg_errcode_t
-check_arrival_add_next_nodes (mctx, str_idx, cur_nodes, next_nodes)
- re_match_context_t *mctx;
- int str_idx;
- re_node_set *cur_nodes, *next_nodes;
-{
- re_dfa_t *const dfa = mctx->dfa;
- int cur_idx;
- reg_errcode_t err;
- re_node_set union_set;
- re_node_set_init_empty (&union_set);
- for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
- {
- int naccepted = 0;
- int cur_node = cur_nodes->elems[cur_idx];
- re_token_type_t type = dfa->nodes[cur_node].type;
- if (IS_EPSILON_NODE (type))
- continue;
-#ifdef RE_ENABLE_I18N
- /* If the node may accept `multi byte'. */
- if (ACCEPT_MB_NODE (type))
- {
- naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input,
- str_idx);
- if (naccepted > 1)
- {
- re_dfastate_t *dest_state;
- int next_node = dfa->nexts[cur_node];
- int next_idx = str_idx + naccepted;
- dest_state = mctx->state_log[next_idx];
- re_node_set_empty (&union_set);
- if (dest_state)
- {
- err = re_node_set_merge (&union_set, &dest_state->nodes);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&union_set);
- return err;
- }
- }
- err = re_node_set_insert (&union_set, next_node);
- if (BE (err < 0, 0))
- {
- re_node_set_free (&union_set);
- return REG_ESPACE;
- }
- mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
- &union_set);
- if (BE (mctx->state_log[next_idx] == NULL
- && err != REG_NOERROR, 0))
- {
- re_node_set_free (&union_set);
- return err;
- }
- }
- }
-#endif /* RE_ENABLE_I18N */
- if (naccepted
- || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
- {
- err = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
- if (BE (err < 0, 0))
- {
- re_node_set_free (&union_set);
- return REG_ESPACE;
- }
- }
- }
- re_node_set_free (&union_set);
- return REG_NOERROR;
-}
-
-/* For all the nodes in CUR_NODES, add the epsilon closures of them to
- CUR_NODES, however exclude the nodes which are:
- - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN.
- - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN.
-*/
-
-static reg_errcode_t
-check_arrival_expand_ecl (dfa, cur_nodes, ex_subexp, type)
- re_dfa_t *dfa;
- re_node_set *cur_nodes;
- int ex_subexp, type;
-{
- reg_errcode_t err;
- int idx, outside_node;
- re_node_set new_nodes;
-#ifdef DEBUG
- assert (cur_nodes->nelem);
-#endif
- err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
- if (BE (err != REG_NOERROR, 0))
- return err;
- /* Create a new node set NEW_NODES with the nodes which are epsilon
- closures of the node in CUR_NODES. */
-
- for (idx = 0; idx < cur_nodes->nelem; ++idx)
- {
- int cur_node = cur_nodes->elems[idx];
- re_node_set *eclosure = dfa->eclosures + cur_node;
- outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type);
- if (outside_node == -1)
- {
- /* There are no problematic nodes, just merge them. */
- err = re_node_set_merge (&new_nodes, eclosure);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&new_nodes);
- return err;
- }
- }
- else
- {
- /* There are problematic nodes, re-calculate incrementally. */
- err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
- ex_subexp, type);
- if (BE (err != REG_NOERROR, 0))
- {
- re_node_set_free (&new_nodes);
- return err;
- }
- }
- }
- re_node_set_free (cur_nodes);
- *cur_nodes = new_nodes;
- return REG_NOERROR;
-}
-
-/* Helper function for check_arrival_expand_ecl.
- Check incrementally the epsilon closure of TARGET, and if it isn't
- problematic append it to DST_NODES. */
-
-static reg_errcode_t
-check_arrival_expand_ecl_sub (dfa, dst_nodes, target, ex_subexp, type)
- re_dfa_t *dfa;
- int target, ex_subexp, type;
- re_node_set *dst_nodes;
-{
- int cur_node;
- for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);)
- {
- int err;
-
- if (dfa->nodes[cur_node].type == type
- && dfa->nodes[cur_node].opr.idx == ex_subexp)
- {
- if (type == OP_CLOSE_SUBEXP)
- {
- err = re_node_set_insert (dst_nodes, cur_node);
- if (BE (err == -1, 0))
- return REG_ESPACE;
- }
- break;
- }
- err = re_node_set_insert (dst_nodes, cur_node);
- if (BE (err == -1, 0))
- return REG_ESPACE;
- if (dfa->edests[cur_node].nelem == 0)
- break;
- if (dfa->edests[cur_node].nelem == 2)
- {
- err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
- dfa->edests[cur_node].elems[1],
- ex_subexp, type);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- cur_node = dfa->edests[cur_node].elems[0];
- }
- return REG_NOERROR;
-}
-
-
-/* For all the back references in the current state, calculate the
- destination of the back references by the appropriate entry
- in MCTX->BKREF_ENTS. */
-
-static reg_errcode_t
-expand_bkref_cache (mctx, cur_nodes, cur_str, last_str, subexp_num,
- type)
- re_match_context_t *mctx;
- int cur_str, last_str, subexp_num, type;
- re_node_set *cur_nodes;
-{
- re_dfa_t *const dfa = mctx->dfa;
- reg_errcode_t err;
- int cache_idx, cache_idx_start;
- /* The current state. */
-
- cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
- for (cache_idx = cache_idx_start; cache_idx < mctx->nbkref_ents; ++cache_idx)
- {
- int to_idx, next_node;
- struct re_backref_cache_entry *ent = mctx->bkref_ents + cache_idx;
- if (ent->str_idx > cur_str)
- break;
- /* Is this entry ENT is appropriate? */
- if (!re_node_set_contains (cur_nodes, ent->node))
- continue; /* No. */
-
- to_idx = cur_str + ent->subexp_to - ent->subexp_from;
- /* Calculate the destination of the back reference, and append it
- to MCTX->STATE_LOG. */
- if (to_idx == cur_str)
- {
- /* The backreference did epsilon transit, we must re-check all the
- node in the current state. */
- re_node_set new_dests;
- reg_errcode_t err2, err3;
- next_node = dfa->edests[ent->node].elems[0];
- if (re_node_set_contains (cur_nodes, next_node))
- continue;
- err = re_node_set_init_1 (&new_dests, next_node);
- err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
- err3 = re_node_set_merge (cur_nodes, &new_dests);
- re_node_set_free (&new_dests);
- if (BE (err != REG_NOERROR || err2 != REG_NOERROR
- || err3 != REG_NOERROR, 0))
- {
- err = (err != REG_NOERROR ? err
- : (err2 != REG_NOERROR ? err2 : err3));
- return err;
- }
- /* TODO: It is still inefficient... */
- cache_idx = cache_idx_start - 1;
- continue;
- }
- else
- {
- re_node_set union_set;
- next_node = dfa->nexts[ent->node];
- if (mctx->state_log[to_idx])
- {
- int ret;
- if (re_node_set_contains (&mctx->state_log[to_idx]->nodes,
- next_node))
- continue;
- err = re_node_set_init_copy (&union_set,
- &mctx->state_log[to_idx]->nodes);
- ret = re_node_set_insert (&union_set, next_node);
- if (BE (err != REG_NOERROR || ret < 0, 0))
- {
- re_node_set_free (&union_set);
- err = err != REG_NOERROR ? err : REG_ESPACE;
- return err;
- }
- }
- else
- {
- err = re_node_set_init_1 (&union_set, next_node);
- if (BE (err != REG_NOERROR, 0))
- return err;
- }
- mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
- re_node_set_free (&union_set);
- if (BE (mctx->state_log[to_idx] == NULL
- && err != REG_NOERROR, 0))
- return err;
- }
- }
- return REG_NOERROR;
-}
-
-/* Build transition table for the state.
- Return the new table if succeeded, otherwise return NULL. */
-
-static int
-build_trtable (dfa, state)
- re_dfa_t *dfa;
- re_dfastate_t *state;
-{
- reg_errcode_t err;
- int i, j, ch;
- unsigned int elem, mask;
- int dests_node_malloced = 0, dest_states_malloced = 0;
- int ndests; /* Number of the destination states from `state'. */
- int need_word_trtable = 0;
- re_dfastate_t **trtable;
- re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl;
- re_node_set follows, *dests_node;
- bitset *dests_ch;
- bitset acceptable;
-
- /* We build DFA states which corresponds to the destination nodes
- from `state'. `dests_node[i]' represents the nodes which i-th
- destination state contains, and `dests_ch[i]' represents the
- characters which i-th destination state accepts. */
-#ifdef _LIBC
- if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX))
- dests_node = (re_node_set *)
- alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX);
- else
-#endif
- {
- dests_node = (re_node_set *)
- malloc ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX);
- if (BE (dests_node == NULL, 0))
- return 0;
- dests_node_malloced = 1;
- }
- dests_ch = (bitset *) (dests_node + SBC_MAX);
-
- /* At first, group all nodes belonging to `state' into several
- destinations. */
- ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
- if (BE (ndests <= 0, 0))
- {
- if (dests_node_malloced)
- free (dests_node);
- if (ndests == 0)
- state->trtable = (re_dfastate_t **)
- calloc (sizeof (re_dfastate_t *), SBC_MAX);;
-
- /* Return 0 in case of an error, 1 otherwise. */
- return state->trtable != NULL;
- }
-
- err = re_node_set_alloc (&follows, ndests + 1);
- if (BE (err != REG_NOERROR, 0))
- goto out_free;
-
-#ifdef _LIBC
- if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX
- + ndests * 3 * sizeof (re_dfastate_t *)))
- dest_states = (re_dfastate_t **)
- alloca (ndests * 3 * sizeof (re_dfastate_t *));
- else
-#endif
- {
- dest_states = (re_dfastate_t **)
- malloc (ndests * 3 * sizeof (re_dfastate_t *));
- if (BE (dest_states == NULL, 0))
- {
-out_free:
- if (dest_states_malloced)
- free (dest_states);
- re_node_set_free (&follows);
- for (i = 0; i < ndests; ++i)
- re_node_set_free (dests_node + i);
- if (dests_node_malloced)
- free (dests_node);
- return 0;
- }
- dest_states_malloced = 1;
- }
- dest_states_word = dest_states + ndests;
- dest_states_nl = dest_states_word + ndests;
- bitset_empty (acceptable);
-
- /* Then build the states for all destinations. */
- for (i = 0; i < ndests; ++i)
- {
- int next_node;
- re_node_set_empty (&follows);
- /* Merge the follows of this destination states. */
- for (j = 0; j < dests_node[i].nelem; ++j)
- {
- next_node = dfa->nexts[dests_node[i].elems[j]];
- if (next_node != -1)
- {
- err = re_node_set_merge (&follows, dfa->eclosures + next_node);
- if (BE (err != REG_NOERROR, 0))
- goto out_free;
- }
- }
- dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
- if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0))
- goto out_free;
- /* If the new state has context constraint,
- build appropriate states for these contexts. */
- if (dest_states[i]->has_constraint)
- {
- dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
- CONTEXT_WORD);
- if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0))
- goto out_free;
-
-#ifdef RE_ENABLE_I18N
- if (dest_states[i] != dest_states_word[i]
- && dfa->mb_cur_max > 1)
- need_word_trtable = 1;
-#endif
-
- dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
- CONTEXT_NEWLINE);
- if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0))
- goto out_free;
- }
- else
- {
- dest_states_word[i] = dest_states[i];
- dest_states_nl[i] = dest_states[i];
- }
- bitset_merge (acceptable, dests_ch[i]);
- }
-
- if (!BE (need_word_trtable, 0))
- {
- /* We don't care about whether the following character is a word
- character, or we are in a single-byte character set so we can
- discern by looking at the character code: allocate a
- 256-entry transition table. */
- trtable = (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
- if (BE (trtable == NULL, 0))
- goto out_free;
-
- /* For all characters ch...: */
- for (i = 0; i < BITSET_UINTS; ++i)
- for (ch = i * UINT_BITS, elem = acceptable[i], mask = 1;
- elem;
- mask <<= 1, elem >>= 1, ++ch)
- if (BE (elem & 1, 0))
- {
- /* There must be exactly one destination which accepts
- character ch. See group_nodes_into_DFAstates. */
- for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
- ;
-
- /* j-th destination accepts the word character ch. */
- if (dfa->word_char[i] & mask)
- trtable[ch] = dest_states_word[j];
- else
- trtable[ch] = dest_states[j];
- }
- }
-#ifdef RE_ENABLE_I18N
- else
- {
- /* We care about whether the following character is a word
- character, and we are in a multi-byte character set: discern
- by looking at the character code: build two 256-entry
- transition tables, one starting at trtable[0] and one
- starting at trtable[SBC_MAX]. */
- trtable = (re_dfastate_t **) calloc (sizeof (re_dfastate_t *),
- 2 * SBC_MAX);
- if (BE (trtable == NULL, 0))
- goto out_free;
-
- /* For all characters ch...: */
- for (i = 0; i < BITSET_UINTS; ++i)
- for (ch = i * UINT_BITS, elem = acceptable[i], mask = 1;
- elem;
- mask <<= 1, elem >>= 1, ++ch)
- if (BE (elem & 1, 0))
- {
- /* There must be exactly one destination which accepts
- character ch. See group_nodes_into_DFAstates. */
- for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
- ;
-
- /* j-th destination accepts the word character ch. */
- trtable[ch] = dest_states[j];
- trtable[ch + SBC_MAX] = dest_states_word[j];
- }
- }
-#endif
-
- /* new line */
- if (bitset_contain (acceptable, NEWLINE_CHAR))
- {
- /* The current state accepts newline character. */
- for (j = 0; j < ndests; ++j)
- if (bitset_contain (dests_ch[j], NEWLINE_CHAR))
- {
- /* k-th destination accepts newline character. */
- trtable[NEWLINE_CHAR] = dest_states_nl[j];
- if (need_word_trtable)
- trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j];
- /* There must be only one destination which accepts
- newline. See group_nodes_into_DFAstates. */
- break;
- }
- }
-
- if (dest_states_malloced)
- free (dest_states);
-
- re_node_set_free (&follows);
- for (i = 0; i < ndests; ++i)
- re_node_set_free (dests_node + i);
-
- if (dests_node_malloced)
- free (dests_node);
-
- if (need_word_trtable)
- state->word_trtable = trtable;
- else
- state->trtable = trtable;
-
- return 1;
-}
-
-/* Group all nodes belonging to STATE into several destinations.
- Then for all destinations, set the nodes belonging to the destination
- to DESTS_NODE[i] and set the characters accepted by the destination
- to DEST_CH[i]. This function return the number of destinations. */
-
-static int
-group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch)
- re_dfa_t *dfa;
- const re_dfastate_t *state;
- re_node_set *dests_node;
- bitset *dests_ch;
-{
- reg_errcode_t err;
- int i, j, k;
- int ndests; /* Number of the destinations from `state'. */
- bitset accepts; /* Characters a node can accept. */
- const re_node_set *cur_nodes = &state->nodes;
- bitset_empty (accepts);
- ndests = 0;
-
- /* For all the nodes belonging to `state', */
- for (i = 0; i < cur_nodes->nelem; ++i)
- {
- re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
- re_token_type_t type = node->type;
- unsigned int constraint = node->constraint;
-
- /* Enumerate all single byte character this node can accept. */
- if (type == CHARACTER)
- bitset_set (accepts, node->opr.c);
- else if (type == SIMPLE_BRACKET)
- {
- bitset_merge (accepts, node->opr.sbcset);
- }
- else if (type == OP_PERIOD)
- {
-#ifdef RE_ENABLE_I18N
- if (dfa->mb_cur_max > 1)
- bitset_merge (accepts, dfa->sb_char);
- else
-#endif
- bitset_set_all (accepts);
- if (!(dfa->syntax & RE_DOT_NEWLINE))
- bitset_clear (accepts, '\n');
- if (dfa->syntax & RE_DOT_NOT_NULL)
- bitset_clear (accepts, '\0');
- }
-#ifdef RE_ENABLE_I18N
- else if (type == OP_UTF8_PERIOD)
- {
- memset (accepts, 255, sizeof (unsigned int) * BITSET_UINTS / 2);
- if (!(dfa->syntax & RE_DOT_NEWLINE))
- bitset_clear (accepts, '\n');
- if (dfa->syntax & RE_DOT_NOT_NULL)
- bitset_clear (accepts, '\0');
- }
-#endif
- else
- continue;
-
- /* Check the `accepts' and sift the characters which are not
- match it the context. */
- if (constraint)
- {
- if (constraint & NEXT_NEWLINE_CONSTRAINT)
- {
- int accepts_newline = bitset_contain (accepts, NEWLINE_CHAR);
- bitset_empty (accepts);
- if (accepts_newline)
- bitset_set (accepts, NEWLINE_CHAR);
- else
- continue;
- }
- if (constraint & NEXT_ENDBUF_CONSTRAINT)
- {
- bitset_empty (accepts);
- continue;
- }
-
- if (constraint & NEXT_WORD_CONSTRAINT)
- {
- unsigned int any_set = 0;
- if (type == CHARACTER && !node->word_char)
- {
- bitset_empty (accepts);
- continue;
- }
-#ifdef RE_ENABLE_I18N
- if (dfa->mb_cur_max > 1)
- for (j = 0; j < BITSET_UINTS; ++j)
- any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
- else
-#endif
- for (j = 0; j < BITSET_UINTS; ++j)
- any_set |= (accepts[j] &= dfa->word_char[j]);
- if (!any_set)
- continue;
- }
- if (constraint & NEXT_NOTWORD_CONSTRAINT)
- {
- unsigned int any_set = 0;
- if (type == CHARACTER && node->word_char)
- {
- bitset_empty (accepts);
- continue;
- }
-#ifdef RE_ENABLE_I18N
- if (dfa->mb_cur_max > 1)
- for (j = 0; j < BITSET_UINTS; ++j)
- any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
- else
-#endif
- for (j = 0; j < BITSET_UINTS; ++j)
- any_set |= (accepts[j] &= ~dfa->word_char[j]);
- if (!any_set)
- continue;
- }
- }
-
- /* Then divide `accepts' into DFA states, or create a new
- state. Above, we make sure that accepts is not empty. */
- for (j = 0; j < ndests; ++j)
- {
- bitset intersec; /* Intersection sets, see below. */
- bitset remains;
- /* Flags, see below. */
- int has_intersec, not_subset, not_consumed;
-
- /* Optimization, skip if this state doesn't accept the character. */
- if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c))
- continue;
-
- /* Enumerate the intersection set of this state and `accepts'. */
- has_intersec = 0;
- for (k = 0; k < BITSET_UINTS; ++k)
- has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k];
- /* And skip if the intersection set is empty. */
- if (!has_intersec)
- continue;
-
- /* Then check if this state is a subset of `accepts'. */
- not_subset = not_consumed = 0;
- for (k = 0; k < BITSET_UINTS; ++k)
- {
- not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k];
- not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k];
- }
-
- /* If this state isn't a subset of `accepts', create a
- new group state, which has the `remains'. */
- if (not_subset)
- {
- bitset_copy (dests_ch[ndests], remains);
- bitset_copy (dests_ch[j], intersec);
- err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
- if (BE (err != REG_NOERROR, 0))
- goto error_return;
- ++ndests;
- }
-
- /* Put the position in the current group. */
- err = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
- if (BE (err < 0, 0))
- goto error_return;
-
- /* If all characters are consumed, go to next node. */
- if (!not_consumed)
- break;
- }
- /* Some characters remain, create a new group. */
- if (j == ndests)
- {
- bitset_copy (dests_ch[ndests], accepts);
- err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
- if (BE (err != REG_NOERROR, 0))
- goto error_return;
- ++ndests;
- bitset_empty (accepts);
- }
- }
- return ndests;
- error_return:
- for (j = 0; j < ndests; ++j)
- re_node_set_free (dests_node + j);
- return -1;
-}
-
-#ifdef RE_ENABLE_I18N
-/* Check how many bytes the node `dfa->nodes[node_idx]' accepts.
- Return the number of the bytes the node accepts.
- STR_IDX is the current index of the input string.
-
- This function handles the nodes which can accept one character, or
- one collating element like '.', '[a-z]', opposite to the other nodes
- can only accept one byte. */
-
-static int
-check_node_accept_bytes (dfa, node_idx, input, str_idx)
- re_dfa_t *dfa;
- int node_idx, str_idx;
- const re_string_t *input;
-{
- const re_token_t *node = dfa->nodes + node_idx;
- int char_len, elem_len;
- int i;
-
- if (BE (node->type == OP_UTF8_PERIOD, 0))
- {
- unsigned char c = re_string_byte_at (input, str_idx), d;
- if (BE (c < 0xc2, 1))
- return 0;
-
- if (str_idx + 2 > input->len)
- return 0;
-
- d = re_string_byte_at (input, str_idx + 1);
- if (c < 0xe0)
- return (d < 0x80 || d > 0xbf) ? 0 : 2;
- else if (c < 0xf0)
- {
- char_len = 3;
- if (c == 0xe0 && d < 0xa0)
- return 0;
- }
- else if (c < 0xf8)
- {
- char_len = 4;
- if (c == 0xf0 && d < 0x90)
- return 0;
- }
- else if (c < 0xfc)
- {
- char_len = 5;
- if (c == 0xf8 && d < 0x88)
- return 0;
- }
- else if (c < 0xfe)
- {
- char_len = 6;
- if (c == 0xfc && d < 0x84)
- return 0;
- }
- else
- return 0;
-
- if (str_idx + char_len > input->len)
- return 0;
-
- for (i = 1; i < char_len; ++i)
- {
- d = re_string_byte_at (input, str_idx + i);
- if (d < 0x80 || d > 0xbf)
- return 0;
- }
- return char_len;
- }
-
- char_len = re_string_char_size_at (input, str_idx);
- if (node->type == OP_PERIOD)
- {
- if (char_len <= 1)
- return 0;
- /* FIXME: I don't think this if is needed, as both '\n'
- and '\0' are char_len == 1. */
- /* '.' accepts any one character except the following two cases. */
- if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
- re_string_byte_at (input, str_idx) == '\n') ||
- ((dfa->syntax & RE_DOT_NOT_NULL) &&
- re_string_byte_at (input, str_idx) == '\0'))
- return 0;
- return char_len;
- }
-
- elem_len = re_string_elem_size_at (input, str_idx);
- if ((elem_len <= 1 && char_len <= 1) || char_len == 0)
- return 0;
-
- if (node->type == COMPLEX_BRACKET)
- {
- const re_charset_t *cset = node->opr.mbcset;
-# ifdef _LIBC
- const unsigned char *pin = ((char *) re_string_get_buffer (input)
- + str_idx);
- int j;
- uint32_t nrules;
-# endif /* _LIBC */
- int match_len = 0;
- wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
- ? re_string_wchar_at (input, str_idx) : 0);
-
- /* match with multibyte character? */
- for (i = 0; i < cset->nmbchars; ++i)
- if (wc == cset->mbchars[i])
- {
- match_len = char_len;
- goto check_node_accept_bytes_match;
- }
- /* match with character_class? */
- for (i = 0; i < cset->nchar_classes; ++i)
- {
- wctype_t wt = cset->char_classes[i];
- if (__iswctype (wc, wt))
- {
- match_len = char_len;
- goto check_node_accept_bytes_match;
- }
- }
-
-# ifdef _LIBC
- nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
- if (nrules != 0)
- {
- unsigned int in_collseq = 0;
- const int32_t *table, *indirect;
- const unsigned char *weights, *extra;
- const char *collseqwc;
- int32_t idx;
- /* This #include defines a local function! */
-# include
-
- /* match with collating_symbol? */
- if (cset->ncoll_syms)
- extra = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
- for (i = 0; i < cset->ncoll_syms; ++i)
- {
- const unsigned char *coll_sym = extra + cset->coll_syms[i];
- /* Compare the length of input collating element and
- the length of current collating element. */
- if (*coll_sym != elem_len)
- continue;
- /* Compare each bytes. */
- for (j = 0; j < *coll_sym; j++)
- if (pin[j] != coll_sym[1 + j])
- break;
- if (j == *coll_sym)
- {
- /* Match if every bytes is equal. */
- match_len = j;
- goto check_node_accept_bytes_match;
- }
- }
-
- if (cset->nranges)
- {
- if (elem_len <= char_len)
- {
- collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
- in_collseq = __collseq_table_lookup (collseqwc, wc);
- }
- else
- in_collseq = find_collation_sequence_value (pin, elem_len);
- }
- /* match with range expression? */
- for (i = 0; i < cset->nranges; ++i)
- if (cset->range_starts[i] <= in_collseq
- && in_collseq <= cset->range_ends[i])
- {
- match_len = elem_len;
- goto check_node_accept_bytes_match;
- }
-
- /* match with equivalence_class? */
- if (cset->nequiv_classes)
- {
- const unsigned char *cp = pin;
- table = (const int32_t *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
- weights = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
- extra = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
- indirect = (const int32_t *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
- idx = findidx (&cp);
- if (idx > 0)
- for (i = 0; i < cset->nequiv_classes; ++i)
- {
- int32_t equiv_class_idx = cset->equiv_classes[i];
- size_t weight_len = weights[idx];
- if (weight_len == weights[equiv_class_idx])
- {
- int cnt = 0;
- while (cnt <= weight_len
- && (weights[equiv_class_idx + 1 + cnt]
- == weights[idx + 1 + cnt]))
- ++cnt;
- if (cnt > weight_len)
- {
- match_len = elem_len;
- goto check_node_accept_bytes_match;
- }
- }
- }
- }
- }
- else
-# endif /* _LIBC */
- {
- /* match with range expression? */
-#if __GNUC__ >= 2
- wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
-#else
- wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
- cmp_buf[2] = wc;
-#endif
- for (i = 0; i < cset->nranges; ++i)
- {
- cmp_buf[0] = cset->range_starts[i];
- cmp_buf[4] = cset->range_ends[i];
- if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
- && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
- {
- match_len = char_len;
- goto check_node_accept_bytes_match;
- }
- }
- }
- check_node_accept_bytes_match:
- if (!cset->non_match)
- return match_len;
- else
- {
- if (match_len > 0)
- return 0;
- else
- return (elem_len > char_len) ? elem_len : char_len;
- }
- }
- return 0;
-}
-
-# ifdef _LIBC
-static unsigned int
-find_collation_sequence_value (mbs, mbs_len)
- const unsigned char *mbs;
- size_t mbs_len;
-{
- uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
- if (nrules == 0)
- {
- if (mbs_len == 1)
- {
- /* No valid character. Match it as a single byte character. */
- const unsigned char *collseq = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
- return collseq[mbs[0]];
- }
- return UINT_MAX;
- }
- else
- {
- int32_t idx;
- const unsigned char *extra = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
- int32_t extrasize = (const unsigned char *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra;
-
- for (idx = 0; idx < extrasize;)
- {
- int mbs_cnt, found = 0;
- int32_t elem_mbs_len;
- /* Skip the name of collating element name. */
- idx = idx + extra[idx] + 1;
- elem_mbs_len = extra[idx++];
- if (mbs_len == elem_mbs_len)
- {
- for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt)
- if (extra[idx + mbs_cnt] != mbs[mbs_cnt])
- break;
- if (mbs_cnt == elem_mbs_len)
- /* Found the entry. */
- found = 1;
- }
- /* Skip the byte sequence of the collating element. */
- idx += elem_mbs_len;
- /* Adjust for the alignment. */
- idx = (idx + 3) & ~3;
- /* Skip the collation sequence value. */
- idx += sizeof (uint32_t);
- /* Skip the wide char sequence of the collating element. */
- idx = idx + sizeof (uint32_t) * (extra[idx] + 1);
- /* If we found the entry, return the sequence value. */
- if (found)
- return *(uint32_t *) (extra + idx);
- /* Skip the collation sequence value. */
- idx += sizeof (uint32_t);
- }
- return UINT_MAX;
- }
-}
-# endif /* _LIBC */
-#endif /* RE_ENABLE_I18N */
-
-/* Check whether the node accepts the byte which is IDX-th
- byte of the INPUT. */
-
-static int
-check_node_accept (mctx, node, idx)
- const re_match_context_t *mctx;
- const re_token_t *node;
- int idx;
-{
- re_dfa_t *const dfa = mctx->dfa;
- unsigned char ch;
- if (node->constraint)
- {
- /* The node has constraints. Check whether the current context
- satisfies the constraints. */
- unsigned int context = re_string_context_at (&mctx->input, idx,
- mctx->eflags);
- if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
- return 0;
- }
- ch = re_string_byte_at (&mctx->input, idx);
- switch (node->type)
- {
- case CHARACTER:
- return node->opr.c == ch;
- case SIMPLE_BRACKET:
- return bitset_contain (node->opr.sbcset, ch);
-#ifdef RE_ENABLE_I18N
- case OP_UTF8_PERIOD:
- if (ch >= 0x80)
- return 0;
- /* FALLTHROUGH */
-#endif
- case OP_PERIOD:
- return !((ch == '\n' && !(dfa->syntax & RE_DOT_NEWLINE))
- || (ch == '\0' && (dfa->syntax & RE_DOT_NOT_NULL)));
- default:
- return 0;
- }
-}
-
-/* Extend the buffers, if the buffers have run out. */
-
-static reg_errcode_t
-extend_buffers (mctx)
- re_match_context_t *mctx;
-{
- reg_errcode_t ret;
- re_string_t *pstr = &mctx->input;
-
- /* Double the lengthes of the buffers. */
- ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
-
- if (mctx->state_log != NULL)
- {
- /* And double the length of state_log. */
- /* XXX We have no indication of the size of this buffer. If this
- allocation fail we have no indication that the state_log array
- does not have the right size. */
- re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
- pstr->bufs_len + 1);
- if (BE (new_array == NULL, 0))
- return REG_ESPACE;
- mctx->state_log = new_array;
- }
-
- /* Then reconstruct the buffers. */
- if (pstr->icase)
- {
-#ifdef RE_ENABLE_I18N
- if (pstr->mb_cur_max > 1)
- {
- ret = build_wcs_upper_buffer (pstr);
- if (BE (ret != REG_NOERROR, 0))
- return ret;
- }
- else
-#endif /* RE_ENABLE_I18N */
- build_upper_buffer (pstr);
- }
- else
- {
-#ifdef RE_ENABLE_I18N
- if (pstr->mb_cur_max > 1)
- build_wcs_buffer (pstr);
- else
-#endif /* RE_ENABLE_I18N */
- {
- if (pstr->trans != NULL)
- re_string_translate_buffer (pstr);
- }
- }
- return REG_NOERROR;
-}
-
-
-/* Functions for matching context. */
-
-/* Initialize MCTX. */
-
-static reg_errcode_t
-match_ctx_init (mctx, eflags, n)
- re_match_context_t *mctx;
- int eflags, n;
-{
- mctx->eflags = eflags;
- mctx->match_last = -1;
- if (n > 0)
- {
- mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
- mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
- if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0))
- return REG_ESPACE;
- }
- /* Already zero-ed by the caller.
- else
- mctx->bkref_ents = NULL;
- mctx->nbkref_ents = 0;
- mctx->nsub_tops = 0; */
- mctx->abkref_ents = n;
- mctx->max_mb_elem_len = 1;
- mctx->asub_tops = n;
- return REG_NOERROR;
-}
-
-/* Clean the entries which depend on the current input in MCTX.
- This function must be invoked when the matcher changes the start index
- of the input, or changes the input string. */
-
-static void
-match_ctx_clean (mctx)
- re_match_context_t *mctx;
-{
- int st_idx;
- for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
- {
- int sl_idx;
- re_sub_match_top_t *top = mctx->sub_tops[st_idx];
- for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx)
- {
- re_sub_match_last_t *last = top->lasts[sl_idx];
- re_free (last->path.array);
- re_free (last);
- }
- re_free (top->lasts);
- if (top->path)
- {
- re_free (top->path->array);
- re_free (top->path);
- }
- free (top);
- }
-
- mctx->nsub_tops = 0;
- mctx->nbkref_ents = 0;
-}
-
-/* Free all the memory associated with MCTX. */
-
-static void
-match_ctx_free (mctx)
- re_match_context_t *mctx;
-{
- /* First, free all the memory associated with MCTX->SUB_TOPS. */
- match_ctx_clean (mctx);
- re_free (mctx->sub_tops);
- re_free (mctx->bkref_ents);
-}
-
-
-/* Add a new backreference entry to MCTX.
- Note that we assume that caller never call this function with duplicate
- entry, and call with STR_IDX which isn't smaller than any existing entry.
-*/
-
-static reg_errcode_t
-match_ctx_add_entry (mctx, node, str_idx, from, to)
- re_match_context_t *mctx;
- int node, str_idx, from, to;
-{
- if (mctx->nbkref_ents >= mctx->abkref_ents)
- {
- struct re_backref_cache_entry* new_entry;
- new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
- mctx->abkref_ents * 2);
- if (BE (new_entry == NULL, 0))
- {
- re_free (mctx->bkref_ents);
- return REG_ESPACE;
- }
- mctx->bkref_ents = new_entry;
- memset (mctx->bkref_ents + mctx->nbkref_ents, '\0',
- sizeof (struct re_backref_cache_entry) * mctx->abkref_ents);
- mctx->abkref_ents *= 2;
- }
- mctx->bkref_ents[mctx->nbkref_ents].node = node;
- mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx;
- mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from;
- mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to;
- mctx->bkref_ents[mctx->nbkref_ents++].flag = 0;
- if (mctx->max_mb_elem_len < to - from)
- mctx->max_mb_elem_len = to - from;
- return REG_NOERROR;
-}
-
-/* Search for the first entry which has the same str_idx.
- Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
-
-static int
-search_cur_bkref_entry (mctx, str_idx)
- re_match_context_t *mctx;
- int str_idx;
-{
- int left, right, mid;
- right = mctx->nbkref_ents;
- for (left = 0; left < right;)
- {
- mid = (left + right) / 2;
- if (mctx->bkref_ents[mid].str_idx < str_idx)
- left = mid + 1;
- else
- right = mid;
- }
- return left;
-}
-
-static void
-match_ctx_clear_flag (mctx)
- re_match_context_t *mctx;
-{
- int i;
- for (i = 0; i < mctx->nbkref_ents; ++i)
- mctx->bkref_ents[i].flag = 0;
-}
-
-/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches
- at STR_IDX. */
-
-static reg_errcode_t
-match_ctx_add_subtop (mctx, node, str_idx)
- re_match_context_t *mctx;
- int node, str_idx;
-{
-#ifdef DEBUG
- assert (mctx->sub_tops != NULL);
- assert (mctx->asub_tops > 0);
-#endif
- if (BE (mctx->nsub_tops == mctx->asub_tops, 0))
- {
- int new_asub_tops = mctx->asub_tops * 2;
- re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
- re_sub_match_top_t *,
- new_asub_tops);
- if (BE (new_array == NULL, 0))
- return REG_ESPACE;
- mctx->sub_tops = new_array;
- mctx->asub_tops = new_asub_tops;
- }
- mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
- if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0))
- return REG_ESPACE;
- mctx->sub_tops[mctx->nsub_tops]->node = node;
- mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
- return REG_NOERROR;
-}
-
-/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches
- at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */
-
-static re_sub_match_last_t *
-match_ctx_add_sublast (subtop, node, str_idx)
- re_sub_match_top_t *subtop;
- int node, str_idx;
-{
- re_sub_match_last_t *new_entry;
- if (BE (subtop->nlasts == subtop->alasts, 0))
- {
- int new_alasts = 2 * subtop->alasts + 1;
- re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
- re_sub_match_last_t *,
- new_alasts);
- if (BE (new_array == NULL, 0))
- return NULL;
- subtop->lasts = new_array;
- subtop->alasts = new_alasts;
- }
- new_entry = calloc (1, sizeof (re_sub_match_last_t));
- if (BE (new_entry != NULL, 1))
- {
- subtop->lasts[subtop->nlasts] = new_entry;
- new_entry->node = node;
- new_entry->str_idx = str_idx;
- ++subtop->nlasts;
- }
- return new_entry;
-}
-
-static void
-sift_ctx_init (sctx, sifted_sts, limited_sts, last_node, last_str_idx,
- check_subexp)
- re_sift_context_t *sctx;
- re_dfastate_t **sifted_sts, **limited_sts;
- int last_node, last_str_idx, check_subexp;
-{
- sctx->sifted_states = sifted_sts;
- sctx->limited_states = limited_sts;
- sctx->last_node = last_node;
- sctx->last_str_idx = last_str_idx;
- sctx->check_subexp = check_subexp;
- sctx->cur_bkref = -1;
- sctx->cls_subexp_idx = -1;
- re_node_set_init_empty (&sctx->limits);
-}
diff --git a/lib/snprintf.c b/lib/snprintf.c
new file mode 100644
index 0000000..7062f25
--- /dev/null
+++ b/lib/snprintf.c
@@ -0,0 +1,337 @@
+/* A simplified snprintf, without floating point support */
+
+/* AIX requires this to be the first thing in the file. */
+#ifdef _AIX
+#pragma alloca
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef __GNUC__
+# if HAVE_ALLOCA_H
+# include
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+ char *alloca ();
+# endif
+# endif
+#endif
+
+#ifndef BOOTSTRAP
+#include
+#endif
+#ifdef HAVE_STDARG_H
+#include
+#else
+#include
+#endif
+#ifdef HAVE_STDLIB_H
+#include
+#endif
+#ifdef HAVE_STRING_H
+#include
+#endif
+#include
+
+#include "basicdefs.h"
+
+#define MINUS_FLAG 1
+#define PLUS_FLAG 2
+#define SPACE_FLAG 4
+#define ALTERNATE_FLAG 8
+#define ZERO_FLAG 16
+
+static int
+compute_number_length (num, base, width, prec, flags, minusp)
+ unsigned long num;
+ unsigned base;
+ int width;
+ int prec;
+ int flags;
+ int minusp;
+{
+ int len = 0;
+ int i;
+
+ /* length of the number itself */
+ do
+ {
+ len++;
+ num /= base;
+ }
+ while (num);
+
+ /* ...padded to prec characters */
+ if (prec > len) len = prec;
+
+ /* ...with alternate prefix */
+ if (flags & ALTERNATE_FLAG && (base == 16 || base == 8))
+ len += base / 8;
+
+ /* ...with the sign before it */
+ if (minusp || (flags & SPACE_FLAG) || (flags & PLUS_FLAG))
+ len++;
+
+ /* ...and padded with spaces or zeroes (zeroes go
+ before the sign, actually. This routine does
+ not consider that but vsprintf will). */
+
+ return (width > len) ? width : len;
+}
+
+/* These can't be made into a function... */
+
+#define PARSE_INT_FORMAT(res, args) \
+if (long_flag) \
+ res = va_arg(args, long); \
+else \
+ res = va_arg(args, int)
+
+#define PARSE_UINT_FORMAT(res, args) \
+if (long_flag) \
+ res = va_arg(args, unsigned long); \
+else \
+ res = va_arg(args, unsigned int)
+
+static int
+compute_length (fmt, args)
+ const char *fmt;
+ va_list args;
+{
+ char c;
+ const char *format;
+ size_t sz;
+
+ /* Go through the string and find the correct length. */
+ sz = 0;
+ format = fmt;
+ while (c = *format++)
+ {
+ if (c == '%')
+ {
+ int flags = 0;
+ int width = 0;
+ int prec = -1;
+ int long_flag = 0;
+
+ /* flags */
+ while ((c = *format++))
+ {
+ if (c == '-')
+ flags |= MINUS_FLAG;
+ else if (c == '+')
+ flags |= PLUS_FLAG;
+ else if (c == ' ')
+ flags |= SPACE_FLAG;
+ else if (c == '#')
+ flags |= ALTERNATE_FLAG;
+ else if (c == '0')
+ flags |= ZERO_FLAG;
+ else
+ break;
+ }
+
+ if (flags & PLUS_FLAG)
+ flags &= ~SPACE_FLAG;
+ if (flags & MINUS_FLAG)
+ flags &= ~ZERO_FLAG;
+
+ /* width */
+ if (isdigit (c))
+ do
+ {
+ width = width * 10 + c - '0';
+ c = *format++;
+ }
+ while (isdigit (c));
+ else if (c == '*')
+ {
+ width = va_arg (args, int);
+ c = *format++;
+ }
+
+ /* precision */
+ if (c == '.')
+ {
+ prec = 0;
+ c = *format++;
+ if (isdigit (c))
+ do
+ {
+ prec = prec * 10 + c - '0';
+ c = *format++;
+ }
+ while (isdigit (c));
+ else if (c == '*')
+ {
+ prec = va_arg (args, int);
+ c = *format++;
+ }
+ }
+
+ /* size */
+
+ if (c == 'h')
+ {
+ c = *format++;
+ if (c == 'h')
+ c = *format++;
+ }
+ else if (c == 'l')
+ {
+ long_flag = 1;
+ c = *format++;
+ }
+
+ switch (c)
+ {
+ case 'c':
+ sz += width + 1;
+ break;
+
+ case 's':
+ {
+ int len;
+ char *arg;
+
+ arg = va_arg (args, char *);
+ len = strlen (arg);
+
+ if (prec != -1 && len > prec)
+ len = prec;
+
+ sz += (width > len) ? width : len;
+ break;
+ }
+
+ case 'd':
+ case 'i':
+ {
+ long arg;
+ unsigned long num;
+ int minusp = 0;
+
+ PARSE_INT_FORMAT (arg, args);
+
+ if (arg < 0)
+ {
+ minusp = 1;
+ num = -arg;
+ }
+ else
+ num = arg;
+
+ sz += compute_number_length(num, 10, width,
+ prec, flags, minusp);
+ break;
+ }
+
+ case 'u':
+ {
+ unsigned long arg;
+
+ PARSE_UINT_FORMAT (arg, args);
+
+ sz += compute_number_length(arg, 10, width,
+ prec, flags, 0);
+ break;
+ }
+
+ case 'o':
+ {
+ unsigned long arg;
+
+ PARSE_UINT_FORMAT (arg, args);
+
+ sz += compute_number_length(arg, 8, width,
+ prec, flags, 0);
+ break;
+ }
+
+ case 'p':
+ flags |= ALTERNATE_FLAG;
+ /* fall through */
+
+ case 'x':
+ case 'X':
+ {
+ unsigned long arg;
+
+ PARSE_UINT_FORMAT (arg, args);
+
+ sz += compute_number_length(arg, 16, width,
+ prec, flags, 0);
+ break;
+ }
+
+ case 'n':
+ break;
+
+ case '%':
+ sz++;
+ break;
+
+ default:
+ sz += 2;
+ break;
+ }
+ }
+ else
+ sz++;
+ }
+
+ return sz;
+ }
+
+static int
+my_vsnprintf (str, sz, fmt, args)
+ char *str;
+ size_t sz;
+ const char *fmt;
+ va_list args;
+{
+ char *buf;
+ size_t realsz = compute_length(fmt, args);
+
+ /* Here, we have to count the null character at the end! */
+ if (realsz + 1 < sz)
+ buf = alloca (realsz + 1);
+ else
+ buf = str;
+
+ realsz = vsprintf(buf, fmt, args);
+ if (buf != str)
+ memcpy(str, buf, sz);
+
+ return realsz;
+}
+
+int
+#ifdef HAVE_STDARG_H
+snprintf (char *str, size_t sz, const char *format,...)
+#else
+snprintf (va_alist)
+ va_dcl
+#endif
+{
+ va_list args;
+ int ret;
+#ifdef HAVE_STDARG_H
+ va_start (args, format);
+#else
+ char *str;
+ size_t sz;
+ char *format;
+
+ va_start (args);
+ str = va_arg(args, char *);
+ sz = va_arg(args, size_t);
+ format = va_arg(args, char *);
+#endif
+
+ ret = my_vsnprintf (str, sz, format, args);
+ va_end (args);
+ return ret;
+}
diff --git a/pcre/AUTHORS b/pcre/AUTHORS
new file mode 100644
index 0000000..cafbbee
--- /dev/null
+++ b/pcre/AUTHORS
@@ -0,0 +1,10 @@
+Paolo Bonzini
+
+Based on PCRE-3.4, which was written by:
+
+Philip Hazel
+
+University of Cambridge Computing Service,
+Cambridge, England. Phone: +44 1223 334714.
+
+Copyright (c) 1997-2000 University of Cambridge
diff --git a/pcre/ChangeLog b/pcre/ChangeLog
new file mode 100644
index 0000000..f936e08
--- /dev/null
+++ b/pcre/ChangeLog
@@ -0,0 +1,283 @@
+2004-03-04 Paolo Bonzini
+
+ * regcomp.c: fix bugs in is_endline.
+
+2004-02-29 Paolo Bonzini
+
+ * regperl.c, regposix.c: move common functions...
+ * regcomp.c: ... here.
+
+2004-02-29 Paolo Bonzini
+
+ * internal.h: add OP_ANCHOR_MATCH, ESC_G.
+ * regdebug.c: Likewise.
+ * regexec.c: Likewise.
+ * regperl.c: Likewise.
+ * regposix.c: Likewise.
+ * regstudy.c: Likewise.
+
+2004-01-15 Paolo Bonzini
+
+ * regexp.c: drop regexec2, replace with REG_STARTEND
+ found in NetBSD regexp.
+ * regexp.h: likewise.
+
+2003-09-19 Paolo Bonzini
+
+ * regposix.c: recognize \s and \S.
+
+ * regposix.c: compile (a){0,2} to (a)?(a)? instead
+ of ((a)?(a))? so that it is possible to...
+ * regexec.c: not assign offsets to optional brackets
+ which match nothing, e.g. when matching (b?){1,2} to
+ `b'. Actually, we do assign offsets the first time;
+ this does not hamper the POSIXicity of ssed because
+ anyway we don't get the wrong substitution for the
+ backreference on the RHS: e.g. if you have
+ s/(b?)?/<\1>/ with an empty pattern space, you'll get
+ <> in the pattern space no matter if \1 did not match
+ or if it matched the empty string at offsets [0,0).
+
+2003-01-03 Paolo Bonzini
+
+ * regtables.c (pcre_maketables): add [:blank:]
+ * internal.h (cbit_blank): new
+ * regperl.c: add [:blank:]
+ * regposix.c: add [:blank:]
+
+2002-09-18 Paolo Bonzini
+
+ * regposix.c (pcre_posix_compile_nuls): fix
+ error in determining length of .{1,64}
+ * regperl.c (pcre_perl_compile_nuls): likewise
+
+2002-01-06 Paolo Bonzini
+
+ * regdebug.c: add _ONCE repetitions
+ * regexec.c: likewise
+ * regstudy.c: likewise
+ * internal.h: likewise
+
+2001-12-31 Paolo Bonzini
+
+ ** Version 3.55 released
+
+ * regposix.c (check_escape): inside a character class,
+ parse unknown escapes (like \" or \p) as two separate
+ characters. Signaled by John Fremlin.
+
+2001-12-27 Paolo Bonzini
+
+ ** Version 3.54 released
+
+2001-12-19 Paolo Bonzini
+
+ ** Version 3.53 released
+
+ * regstudy.c (set_boyer_moore, set_start_bits): use new
+ OP_TYPE and OP_TYPENOT* opcodes instead of OP_DIGIT & co.
+ * regdebug.c (pcre_debug): likewise (print them)
+ * regperl.c (compile_branch): likewise (compile them)
+ * regposix.c (compile_branch): likewise (compile them)
+ * internal.h: likewise (define them); refine meaning of
+ bits in ctype table to allow for simpler OP_TYPE* code
+ * regtables.c (pcre_maketables): set newline table.
+
+2001-12-17 Paolo Bonzini
+
+ * regstudy.c (set_bmtable, set_boyer_moore): implemented
+ Boyer-Moore algorithm for first character search
+ * regexec.c (pcre_exec): use the Boyer-Moore data
+
+2001-12-14 Paolo Bonzini
+
+ * internal.h (pcre_extra): encapsulate start_bits in a union,
+ define PCRE_STUDY_BM
+ * regexec.c (pcre_match): access the `data' union in pcre_extra
+ * reginfo.c (pcre_info): likewise
+ * regstudy.c (pcre_study): likewise
+
+2001-12-13 Paolo Bonzini
+
+ *** Version 3.52 released.
+
+2001-12-12 Paolo Bonzini
+
+ * internal.h: add max_match_size to pcre and compile_data
+ * regexec.c (pcre_match): use re->max_match_size
+ information
+ * regexec.c (pcre_match) [DEBUG]: debug first character
+ optimization
+ * regposix.c (compile_branch, pcre_posix_compile_nuls):
+ optimize regexps like xxxxxx$ where xxxxxx
+ cannot match more than a certain number of characters.
+ * regposix.c (is_endline): new function.
+
+2001-10-15 Paolo Bonzini
+
+ *** Version 3.51 released.
+
+2001-10-13 Paolo Bonzini
+
+ * regposix.c(pcre_posix_compile_nuls,
+ basic_to_extended_regexp): fix code overflow
+ bug when a [*+?] is treated as a literal character. This
+ is actually not mandated by POSIX, which specifies
+ "undefined behavior", but an internal error is not what
+ I had in mind...
+
+2001-09-25 Paolo Bonzini
+
+ *** Version 3.50 released.
+
+2001-06-05 Paolo Bonzini
+
+ *** Version 3.49 released
+
+ * regposix.c(check_escape, pcre_posix_compile_nuls): in
+ POSIX regular expressions, inside classes, unrecognized
+ escapes must make the backslash and the following character
+ *really* independent; regexps like [/\] were previously broken.
+
+2001-03-22 Paolo Bonzini
+
+ *** Version 3.48 released
+
+2001-03-02 Paolo Bonzini
+
+ *** Version 3.47 released
+
+2001-02-21 Paolo Bonzini
+
+ *** Version 3.46 released
+
+2001-02-09 Paolo Bonzini
+
+ * regposix.c(compile_branch, read_repeat_counts): support
+ GNU regex's behavior of compiling a{1,2}{2,3} like a{2,6}
+ (multiplying the minimum and maximum counts)
+ * regposix.c(basic_to_extended_regexp): compile * as a
+ literal asterisk if at the start of a branch
+
+2001-01-04 Paolo Bonzini
+
+ * regexp.c(regncomp): pass REG_EXTENDED to the
+ compilation functions (becomes PCRE_EXTENDED)
+
+2001-01-03 Paolo Bonzini
+
+ * regposix.c(check_escape): don't support things like
+ [A\W]: it now means the same as [AW]. However,
+ [\n\r] still means a CR or LF (that is, escapes that
+ are character classes match a literal character, but
+ escapes that match non-printable characters match the
+ character).
+ * regposix.c(compile_branch): simplified to account
+ for the change above.
+
+2000-12-21 Paolo Bonzini
+
+ * pcre.h [BOOTSTRAP]: include malloc.h
+
+ * regexp.c: modified POSIX error messages to resemble
+ PCRE error messages whenever possible.
+
+ * regposix.c(compile_branch): raise an error if unmatched
+ braces are found.
+
+2000-12-11 Paolo Bonzini
+
+ * regposix.c: implement \o and \d like in GNU sed 3.02.80;
+ removed \0.
+
+2000-12-10 Paolo Bonzini
+
+ * regposix.c(pcre_posix_compile_nuls): internationalized.
+ * regperl.c(pcre_compile_nuls): internationalized.
+ * pcregrep.c: internationalized.
+ * internal.h: add standard NLS crap.
+
+ * pcre.h: defined PCRE_ENGLISH_ERRORS
+ * regexp.c: use PCRE_ENGLISH_ERRORS
+
+2000-12-08 Paolo Bonzini
+
+ * regexp.c(regerror): modified a bit to ease i18n.
+
+ * regposix.c: converted the behavior of \ to POSIX
+ (e.g. \11 is not the eleventh backref and \321 is not an
+ octal sequence).
+
+2000-12-07 Paolo Bonzini
+
+ * regdebug.c: added \< and \> to the opcode names table
+
+2000-11-21 Paolo Bonzini
+
+ * regperl.c: handle regexps with embedded NULs
+ * regposix.c: ditto
+
+ * pcre.h: use prototypes
+ * internal.h: ditto
+ * regexp.h: ditto
+
+ * regexp.h: declared regexec2, regncomp
+ * regexp.c: defined regexec2, regncomp
+
+2000-11-16 Paolo Bonzini
+
+ * regposix.c: handle ^ and $ as literals if they're not the first or
+ the last character, respectively.
+
+ * regexp.c(regexec): handle correctly pmatch == NULL
+ * regexec.c(pcre_exec): handle correctly pmatch == NULL
+
+2000-11-15 Paolo Bonzini
+
+ * regposix.c: removed [:^alnum:] and the like; added \`
+ and \'; added basic regular expressions.
+
+ * regexp.c(regnexec): new function
+
+2000-11-14 Paolo Bonzini
+
+ * internal.h: declared ESC_LESS and ESC_GREATER,
+ ESC_FIRST_CONSUME and ESC_LAST_CONSUME, OP_BEG_WORD and OP_END_WORD
+
+ * regexec.c(match): added OP_BEG_WORD and OP_END_WORD
+
+ * regposix.c: created from regperl.c
+
+ * regperl.c(compile_branch): use ESC_FIRST_CONSUME and ESC_LAST_CONSUME
+
+ * regexp.c(regcomp): handle PCRE_DOTALL differently for Perl and POSIX
+ regular expressions.
+
+2000-11-13 Paolo Bonzini
+
+ Started work to merge with sed.
+
+ * AUTHORS: inserted myself...
+ * COPYING: replaced with GNU GPL. Original terms stay in the
+ LICENCE file.
+
+ * Makefile.in: remove libtool usage, not good for a bootstrapping
+ tool such as sed.
+ * configure.in: likewise; also changed AC_CHECK_FUNCS to
+ AC_REPLACE_FUNCS for memmove.
+
+ * regdebug.c: new file, created from part of pcre.c.
+ * regexec.c: new file, created from part of pcre.c. Removed UTF-8.
+ * reginfo.c: new file, created from part of pcre.c.
+ * internal.h: don't do strange things with memmove declarations.
+ * regperl.c: new file, created from part of pcre.c.
+ * pcre.c: split into many sources, removed.
+
+ * regexp.c(regcomp, regexec): new name of pcreposix.c; use pcre_study
+ * regexp.h: new name of pcreposix.h; added re_study member
+
+2000-11-13 Paolo Bonzini
+
+ * pcre.c(pcre_compile): Removed support for UTF-8.
+ The default tables are generated at run-time rather than
+ at compile-time to support cross compiling.
diff --git a/pcre/ChangeLog.pre-sed b/pcre/ChangeLog.pre-sed
new file mode 100644
index 0000000..8ffa65b
--- /dev/null
+++ b/pcre/ChangeLog.pre-sed
@@ -0,0 +1,655 @@
+ChangeLog for PCRE
+------------------
+
+
+Version 3.4 22-Aug-00
+---------------------
+
+1. Fixed typo in pcre.h: unsigned const char * changed to const unsigned char *.
+
+2. Diagnose condition (?(0) as an error instead of crashing on matching.
+
+
+Version 3.3 01-Aug-00
+---------------------
+
+1. If an octal character was given, but the value was greater than \377, it
+was not getting masked to the least significant bits, as documented. This could
+lead to crashes in some systems.
+
+2. Perl 5.6 (if not earlier versions) accepts classes like [a-\d] and treats
+the hyphen as a literal. PCRE used to give an error; it now behaves like Perl.
+
+3. Added the functions pcre_free_substring() and pcre_free_substring_list().
+These just pass their arguments on to (pcre_free)(), but they are provided
+because some uses of PCRE bind it to non-C systems that can call its functions,
+but cannot call free() or pcre_free() directly.
+
+4. Add "make test" as a synonym for "make check". Corrected some comments in
+the Makefile.
+
+5. Add $(DESTDIR)/ in front of all the paths in the "install" target in the
+Makefile.
+
+6. Changed the name of pgrep to pcregrep, because Solaris has introduced a
+command called pgrep for grepping around the active processes.
+
+7. Added the beginnings of support for UTF-8 character strings.
+
+8. Arranged for the Makefile to pass over the settings of CC, CFLAGS, and
+RANLIB to ./ltconfig so that they are used by libtool. I think these are all
+the relevant ones. (AR is not passed because ./ltconfig does its own figuring
+out for the ar command.)
+
+
+Version 3.2 12-May-00
+---------------------
+
+This is purely a bug fixing release.
+
+1. If the pattern /((Z)+|A)*/ was matched agained ZABCDEFG it matched Z instead
+of ZA. This was just one example of several cases that could provoke this bug,
+which was introduced by change 9 of version 2.00. The code for breaking
+infinite loops after an iteration that matches an empty string was't working
+correctly.
+
+2. The pcretest program was not imitating Perl correctly for the pattern /a*/g
+when matched against abbab (for example). After matching an empty string, it
+wasn't forcing anchoring when setting PCRE_NOTEMPTY for the next attempt; this
+caused it to match further down the string than it should.
+
+3. The code contained an inclusion of sys/types.h. It isn't clear why this
+was there because it doesn't seem to be needed, and it causes trouble on some
+systems, as it is not a Standard C header. It has been removed.
+
+4. Made 4 silly changes to the source to avoid stupid compiler warnings that
+were reported on the Macintosh. The changes were from
+
+ while ((c = *(++ptr)) != 0 && c != '\n');
+to
+ while ((c = *(++ptr)) != 0 && c != '\n') ;
+
+Totally extraordinary, but if that's what it takes...
+
+5. PCRE is being used in one environment where neither memmove() nor bcopy() is
+available. Added HAVE_BCOPY and an autoconf test for it; if neither
+HAVE_MEMMOVE nor HAVE_BCOPY is set, use a built-in emulation function which
+assumes the way PCRE uses memmove() (always moving upwards).
+
+6. PCRE is being used in one environment where strchr() is not available. There
+was only one use in pcre.c, and writing it out to avoid strchr() probably gives
+faster code anyway.
+
+
+Version 3.1 09-Feb-00
+---------------------
+
+The only change in this release is the fixing of some bugs in Makefile.in for
+the "install" target:
+
+(1) It was failing to install pcreposix.h.
+
+(2) It was overwriting the pcre.3 man page with the pcreposix.3 man page.
+
+
+Version 3.0 01-Feb-00
+---------------------
+
+1. Add support for the /+ modifier to perltest (to output $` like it does in
+pcretest).
+
+2. Add support for the /g modifier to perltest.
+
+3. Fix pcretest so that it behaves even more like Perl for /g when the pattern
+matches null strings.
+
+4. Fix perltest so that it doesn't do unwanted things when fed an empty
+pattern. Perl treats empty patterns specially - it reuses the most recent
+pattern, which is not what we want. Replace // by /(?#)/ in order to avoid this
+effect.
+
+5. The POSIX interface was broken in that it was just handing over the POSIX
+captured string vector to pcre_exec(), but (since release 2.00) PCRE has
+required a bigger vector, with some working space on the end. This means that
+the POSIX wrapper now has to get and free some memory, and copy the results.
+
+6. Added some simple autoconf support, placing the test data and the
+documentation in separate directories, re-organizing some of the
+information files, and making it build pcre-config (a GNU standard). Also added
+libtool support for building PCRE as a shared library, which is now the
+default.
+
+7. Got rid of the leading zero in the definition of PCRE_MINOR because 08 and
+09 are not valid octal constants. Single digits will be used for minor values
+less than 10.
+
+8. Defined REG_EXTENDED and REG_NOSUB as zero in the POSIX header, so that
+existing programs that set these in the POSIX interface can use PCRE without
+modification.
+
+9. Added a new function, pcre_fullinfo() with an extensible interface. It can
+return all that pcre_info() returns, plus additional data. The pcre_info()
+function is retained for compatibility, but is considered to be obsolete.
+
+10. Added experimental recursion feature (?R) to handle one common case that
+Perl 5.6 will be able to do with (?p{...}).
+
+11. Added support for POSIX character classes like [:alpha:], which Perl is
+adopting.
+
+
+Version 2.08 31-Aug-99
+----------------------
+
+1. When startoffset was not zero and the pattern began with ".*", PCRE was not
+trying to match at the startoffset position, but instead was moving forward to
+the next newline as if a previous match had failed.
+
+2. pcretest was not making use of PCRE_NOTEMPTY when repeating for /g and /G,
+and could get into a loop if a null string was matched other than at the start
+of the subject.
+
+3. Added definitions of PCRE_MAJOR and PCRE_MINOR to pcre.h so the version can
+be distinguished at compile time, and for completeness also added PCRE_DATE.
+
+5. Added Paul Sokolovsky's minor changes to make it easy to compile a Win32 DLL
+in GnuWin32 environments.
+
+
+Version 2.07 29-Jul-99
+----------------------
+
+1. The documentation is now supplied in plain text form and HTML as well as in
+the form of man page sources.
+
+2. C++ compilers don't like assigning (void *) values to other pointer types.
+In particular this affects malloc(). Although there is no problem in Standard
+C, I've put in casts to keep C++ compilers happy.
+
+3. Typo on pcretest.c; a cast of (unsigned char *) in the POSIX regexec() call
+should be (const char *).
+
+4. If NOPOSIX is defined, pcretest.c compiles without POSIX support. This may
+be useful for non-Unix systems who don't want to bother with the POSIX stuff.
+However, I haven't made this a standard facility. The documentation doesn't
+mention it, and the Makefile doesn't support it.
+
+5. The Makefile now contains an "install" target, with editable destinations at
+the top of the file. The pcretest program is not installed.
+
+6. pgrep -V now gives the PCRE version number and date.
+
+7. Fixed bug: a zero repetition after a literal string (e.g. /abcde{0}/) was
+causing the entire string to be ignored, instead of just the last character.
+
+8. If a pattern like /"([^\\"]+|\\.)*"/ is applied in the normal way to a
+non-matching string, it can take a very, very long time, even for strings of
+quite modest length, because of the nested recursion. PCRE now does better in
+some of these cases. It does this by remembering the last required literal
+character in the pattern, and pre-searching the subject to ensure it is present
+before running the real match. In other words, it applies a heuristic to detect
+some types of certain failure quickly, and in the above example, if presented
+with a string that has no trailing " it gives "no match" very quickly.
+
+9. A new runtime option PCRE_NOTEMPTY causes null string matches to be ignored;
+other alternatives are tried instead.
+
+
+Version 2.06 09-Jun-99
+----------------------
+
+1. Change pcretest's output for amount of store used to show just the code
+space, because the remainder (the data block) varies in size between 32-bit and
+64-bit systems.
+
+2. Added an extra argument to pcre_exec() to supply an offset in the subject to
+start matching at. This allows lookbehinds to work when searching for multiple
+occurrences in a string.
+
+3. Added additional options to pcretest for testing multiple occurrences:
+
+ /+ outputs the rest of the string that follows a match
+ /g loops for multiple occurrences, using the new startoffset argument
+ /G loops for multiple occurrences by passing an incremented pointer
+
+4. PCRE wasn't doing the "first character" optimization for patterns starting
+with \b or \B, though it was doing it for other lookbehind assertions. That is,
+it wasn't noticing that a match for a pattern such as /\bxyz/ has to start with
+the letter 'x'. On long subject strings, this gives a significant speed-up.
+
+
+Version 2.05 21-Apr-99
+----------------------
+
+1. Changed the type of magic_number from int to long int so that it works
+properly on 16-bit systems.
+
+2. Fixed a bug which caused patterns starting with .* not to work correctly
+when the subject string contained newline characters. PCRE was assuming
+anchoring for such patterns in all cases, which is not correct because .* will
+not pass a newline unless PCRE_DOTALL is set. It now assumes anchoring only if
+DOTALL is set at top level; otherwise it knows that patterns starting with .*
+must be retried after every newline in the subject.
+
+
+Version 2.04 18-Feb-99
+----------------------
+
+1. For parenthesized subpatterns with repeats whose minimum was zero, the
+computation of the store needed to hold the pattern was incorrect (too large).
+If such patterns were nested a few deep, this could multiply and become a real
+problem.
+
+2. Added /M option to pcretest to show the memory requirement of a specific
+pattern. Made -m a synonym of -s (which does this globally) for compatibility.
+
+3. Subpatterns of the form (regex){n,m} (i.e. limited maximum) were being
+compiled in such a way that the backtracking after subsequent failure was
+pessimal. Something like (a){0,3} was compiled as (a)?(a)?(a)? instead of
+((a)((a)(a)?)?)? with disastrous performance if the maximum was of any size.
+
+
+Version 2.03 02-Feb-99
+----------------------
+
+1. Fixed typo and small mistake in man page.
+
+2. Added 4th condition (GPL supersedes if conflict) and created separate
+LICENCE file containing the conditions.
+
+3. Updated pcretest so that patterns such as /abc\/def/ work like they do in
+Perl, that is the internal \ allows the delimiter to be included in the
+pattern. Locked out the use of \ as a delimiter. If \ immediately follows
+the final delimiter, add \ to the end of the pattern (to test the error).
+
+4. Added the convenience functions for extracting substrings after a successful
+match. Updated pcretest to make it able to test these functions.
+
+
+Version 2.02 14-Jan-99
+----------------------
+
+1. Initialized the working variables associated with each extraction so that
+their saving and restoring doesn't refer to uninitialized store.
+
+2. Put dummy code into study.c in order to trick the optimizer of the IBM C
+compiler for OS/2 into generating correct code. Apparently IBM isn't going to
+fix the problem.
+
+3. Pcretest: the timing code wasn't using LOOPREPEAT for timing execution
+calls, and wasn't printing the correct value for compiling calls. Increased the
+default value of LOOPREPEAT, and the number of significant figures in the
+times.
+
+4. Changed "/bin/rm" in the Makefile to "-rm" so it works on Windows NT.
+
+5. Renamed "deftables" as "dftables" to get it down to 8 characters, to avoid
+a building problem on Windows NT with a FAT file system.
+
+
+Version 2.01 21-Oct-98
+----------------------
+
+1. Changed the API for pcre_compile() to allow for the provision of a pointer
+to character tables built by pcre_maketables() in the current locale. If NULL
+is passed, the default tables are used.
+
+
+Version 2.00 24-Sep-98
+----------------------
+
+1. Since the (?>) facility is in Perl 5.005, don't require PCRE_EXTRA to enable
+it any more.
+
+2. Allow quantification of (?>) groups, and make it work correctly.
+
+3. The first character computation wasn't working for (?>) groups.
+
+4. Correct the implementation of \Z (it is permitted to match on the \n at the
+end of the subject) and add 5.005's \z, which really does match only at the
+very end of the subject.
+
+5. Remove the \X "cut" facility; Perl doesn't have it, and (?> is neater.
+
+6. Remove the ability to specify CASELESS, MULTILINE, DOTALL, and
+DOLLAR_END_ONLY at runtime, to make it possible to implement the Perl 5.005
+localized options. All options to pcre_study() were also removed.
+
+7. Add other new features from 5.005:
+
+ $(?<= positive lookbehind
+ $(?a*))*/ (a PCRE_EXTRA facility).
+
+
+Version 1.00 18-Nov-97
+----------------------
+
+1. Added compile-time macros to support systems such as SunOS4 which don't have
+memmove() or strerror() but have other things that can be used instead.
+
+2. Arranged that "make clean" removes the executables.
+
+
+Version 0.99 27-Oct-97
+----------------------
+
+1. Fixed bug in code for optimizing classes with only one character. It was
+initializing a 32-byte map regardless, which could cause it to run off the end
+of the memory it had got.
+
+2. Added, conditional on PCRE_EXTRA, the proposed (?>REGEX) construction.
+
+
+Version 0.98 22-Oct-97
+----------------------
+
+1. Fixed bug in code for handling temporary memory usage when there are more
+back references than supplied space in the ovector. This could cause segfaults.
+
+
+Version 0.97 21-Oct-97
+----------------------
+
+1. Added the \X "cut" facility, conditional on PCRE_EXTRA.
+
+2. Optimized negated single characters not to use a bit map.
+
+3. Brought error texts together as macro definitions; clarified some of them;
+fixed one that was wrong - it said "range out of order" when it meant "invalid
+escape sequence".
+
+4. Changed some char * arguments to const char *.
+
+5. Added PCRE_NOTBOL and PCRE_NOTEOL (from POSIX).
+
+6. Added the POSIX-style API wrapper in pcreposix.a and testing facilities in
+pcretest.
+
+
+Version 0.96 16-Oct-97
+----------------------
+
+1. Added a simple "pgrep" utility to the distribution.
+
+2. Fixed an incompatibility with Perl: "{" is now treated as a normal character
+unless it appears in one of the precise forms "{ddd}", "{ddd,}", or "{ddd,ddd}"
+where "ddd" means "one or more decimal digits".
+
+3. Fixed serious bug. If a pattern had a back reference, but the call to
+pcre_exec() didn't supply a large enough ovector to record the related
+identifying subpattern, the match always failed. PCRE now remembers the number
+of the largest back reference, and gets some temporary memory in which to save
+the offsets during matching if necessary, in order to ensure that
+backreferences always work.
+
+4. Increased the compatibility with Perl in a number of ways:
+
+ (a) . no longer matches \n by default; an option PCRE_DOTALL is provided
+ to request this handling. The option can be set at compile or exec time.
+
+ (b) $ matches before a terminating newline by default; an option
+ PCRE_DOLLAR_ENDONLY is provided to override this (but not in multiline
+ mode). The option can be set at compile or exec time.
+
+ (c) The handling of \ followed by a digit other than 0 is now supposed to be
+ the same as Perl's. If the decimal number it represents is less than 10
+ or there aren't that many previous left capturing parentheses, an octal
+ escape is read. Inside a character class, it's always an octal escape,
+ even if it is a single digit.
+
+ (d) An escaped but undefined alphabetic character is taken as a literal,
+ unless PCRE_EXTRA is set. Currently this just reserves the remaining
+ escapes.
+
+ (e) {0} is now permitted. (The previous item is removed from the compiled
+ pattern).
+
+5. Changed all the names of code files so that the basic parts are no longer
+than 10 characters, and abolished the teeny "globals.c" file.
+
+6. Changed the handling of character classes; they are now done with a 32-byte
+bit map always.
+
+7. Added the -d and /D options to pcretest to make it possible to look at the
+internals of compilation without having to recompile pcre.
+
+
+Version 0.95 23-Sep-97
+----------------------
+
+1. Fixed bug in pre-pass concerning escaped "normal" characters such as \x5c or
+\x20 at the start of a run of normal characters. These were being treated as
+real characters, instead of the source characters being re-checked.
+
+
+Version 0.94 18-Sep-97
+----------------------
+
+1. The functions are now thread-safe, with the caveat that the global variables
+containing pointers to malloc() and free() or alternative functions are the
+same for all threads.
+
+2. Get pcre_study() to generate a bitmap of initial characters for non-
+anchored patterns when this is possible, and use it if passed to pcre_exec().
+
+
+Version 0.93 15-Sep-97
+----------------------
+
+1. /(b)|(:+)/ was computing an incorrect first character.
+
+2. Add pcre_study() to the API and the passing of pcre_extra to pcre_exec(),
+but not actually doing anything yet.
+
+3. Treat "-" characters in classes that cannot be part of ranges as literals,
+as Perl does (e.g. [-az] or [az-]).
+
+4. Set the anchored flag if a branch starts with .* or .*? because that tests
+all possible positions.
+
+5. Split up into different modules to avoid including unneeded functions in a
+compiled binary. However, compile and exec are still in one module. The "study"
+function is split off.
+
+6. The character tables are now in a separate module whose source is generated
+by an auxiliary program - but can then be edited by hand if required. There are
+now no calls to isalnum(), isspace(), isdigit(), isxdigit(), tolower() or
+toupper() in the code.
+
+7. Turn the malloc/free funtions variables into pcre_malloc and pcre_free and
+make them global. Abolish the function for setting them, as the caller can now
+set them directly.
+
+
+Version 0.92 11-Sep-97
+----------------------
+
+1. A repeat with a fixed maximum and a minimum of 1 for an ordinary character
+(e.g. /a{1,3}/) was broken (I mis-optimized it).
+
+2. Caseless matching was not working in character classes if the characters in
+the pattern were in upper case.
+
+3. Make ranges like [W-c] work in the same way as Perl for caseless matching.
+
+4. Make PCRE_ANCHORED public and accept as a compile option.
+
+5. Add an options word to pcre_exec() and accept PCRE_ANCHORED and
+PCRE_CASELESS at run time. Add escapes \A and \I to pcretest to cause it to
+pass them.
+
+6. Give an error if bad option bits passed at compile or run time.
+
+7. Add PCRE_MULTILINE at compile and exec time, and (?m) as well. Add \M to
+pcretest to cause it to pass that flag.
+
+8. Add pcre_info(), to get the number of identifying subpatterns, the stored
+options, and the first character, if set.
+
+9. Recognize C+ or C{n,m} where n >= 1 as providing a fixed starting character.
+
+
+Version 0.91 10-Sep-97
+----------------------
+
+1. PCRE was failing to diagnose unlimited repeats of subpatterns that could
+match the empty string as in /(a*)*/. It was looping and ultimately crashing.
+
+2. PCRE was looping on encountering an indefinitely repeated back reference to
+a subpattern that had matched an empty string, e.g. /(a|)\1*/. It now does what
+Perl does - treats the match as successful.
+
+****
diff --git a/pcre/LICENCE b/pcre/LICENCE
new file mode 100644
index 0000000..0c7ce9a
--- /dev/null
+++ b/pcre/LICENCE
@@ -0,0 +1,50 @@
+PCRE LICENCE
+------------
+
+PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+Written by: Philip Hazel
+
+University of Cambridge Computing Service,
+Cambridge, England. Phone: +44 1223 334714.
+
+Copyright (c) 1997-2000 University of Cambridge
+
+Permission is granted to anyone to use this software for any purpose on any
+computer system, and to redistribute it freely, subject to the following
+restrictions:
+
+1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission. In practice, this means that if you use
+ PCRE in software which you distribute to others, commercially or
+ otherwise, you must put a sentence like this
+
+ Regular expression support is provided by the PCRE library package,
+ which is open source software, written by Philip Hazel, and copyright
+ by the University of Cambridge, England.
+
+ somewhere reasonably visible in your documentation and in any relevant
+ files or online help data or similar. A reference to the ftp site for
+ the source, that is, to
+
+ ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
+
+ should also be given in the documentation.
+
+3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), or Lesser General Purpose Licence (LGPL),
+ then the terms of that licence shall supersede any condition above with
+ which it is incompatible.
+
+The documentation for PCRE, supplied in the "doc" directory, is distributed
+under the same terms as the software itself.
+
+End
diff --git a/pcre/Makefile.am b/pcre/Makefile.am
new file mode 100644
index 0000000..0e83e32
--- /dev/null
+++ b/pcre/Makefile.am
@@ -0,0 +1,17 @@
+## Process this file with automake to produce Makefile.in
+
+noinst_LIBRARIES = libpcre.a
+noinst_HEADERS = internal.h pcre.h regexp.h
+noinst_PROGRAMS = @PCREGREP@
+EXTRA_PROGRAMS = pcregrep
+EXTRA_DIST = AUTHORS ChangeLog ChangeLog.pre-sed LICENCE README regcomp.c
+
+libpcre_a_SOURCES = regtables.c regsub.c regstudy.c regposix.c regperl.c \
+ reginfo.c regexec.c regexp.c regdebug.c
+
+INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/intl -I$(top_srcdir)/pcre \
+ -I$(top_srcdir)
+
+pcregrep_SOURCES = pcregrep.c
+pcregrep_LDADD = libpcre.a
+
diff --git a/pcre/README b/pcre/README
new file mode 100644
index 0000000..2701858
--- /dev/null
+++ b/pcre/README
@@ -0,0 +1,325 @@
+README file for PCRE (Perl-compatible regular expression library)
+-----------------------------------------------------------------
+
+The latest release of PCRE is always available from
+
+ ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xxx.tar.gz
+
+Note that PCRE as included in super-sed is quite different from the
+original. The implementation has been split into more files, and
+internationalized; a POSIX regular expression parser was added (which in
+turn meant adding a few opcodes to the matcher), UTF-8 support was
+removed, and patterns with embedded nuls were supported. This is what
+will make a version lifted from the site and merged tout-court fail with
+100% probability. In addition, the POSIX expression parser has a special
+optimization that is turned on by expressions like "\n$" (in general,
+expression with a definite maximum length and anchored to the end of
+the pattern), which makes the matcher skip non-relevant parts of the
+subject and leap to its end.
+
+PCRE has its own native API, but a set of "wrapper" functions that are based on
+the POSIX API are also supplied in the library. Note that this still provides
+the ability to use Perl semantics for regular expressions through a non-POSIX
+option flag, REG_PERL. The definition of REG_PERL is a good way to check if
+the POSIX API for regular expression is actually PCRE's implementation.
+
+The header file for the POSIX-style functions is called regexp.h. The official
+POSIX name is regex.h, but I didn't want to risk possible problems with
+existing files of that name by distributing it that way. To use it with an
+existing program that uses the POSIX API, it will have to be renamed or
+pointed at by a link. You will obtain PCRE's behavior and speed, but not Perl
+semantics unless you modify the program to use REG_PERL.
+
+
+Technical Notes about PCRE
+--------------------------
+
+Many years ago I implemented some regular expression functions to an algorithm
+suggested by Martin Richards. These were not Unix-like in form, and were quite
+restricted in what they could do by comparison with Perl. The interesting part
+about the algorithm was that the amount of space required to hold the compiled
+form of an expression was known in advance. The code to apply an expression did
+not operate by backtracking, as the Henry Spencer and Perl code does, but
+instead checked all possibilities simultaneously by keeping a list of current
+states and checking all of them as it advanced through the subject string. (In
+the terminology of Jeffrey Friedl's book, it was a "DFA algorithm".) When the
+pattern was all used up, all remaining states were possible matches, and the
+one matching the longest subset of the subject string was chosen. This did not
+necessarily maximize the individual wild portions of the pattern, as is
+expected in Unix and Perl-style regular expressions.
+
+By contrast, the code originally written by Henry Spencer and subsequently
+heavily modified for Perl actually compiles the expression twice: once in a
+dummy mode in order to find out how much store will be needed, and then for
+real. The execution function operates by backtracking and maximizing (or,
+optionally, minimizing in Perl) the amount of the subject that matches
+individual wild portions of the pattern. This is an "NFA algorithm" in Friedl's
+terminology.
+
+For the set of functions that forms PCRE (which are unrelated to those
+mentioned above), I tried at first to invent an algorithm that used an amount
+of store bounded by a multiple of the number of characters in the pattern, to
+save on compiling time. However, because of the greater complexity in Perl
+regular expressions, I couldn't do this. In any case, a first pass through the
+pattern is needed, in order to find internal flag settings like (?i) at top
+level. So PCRE works by running a very degenerate first pass to calculate a
+maximum store size, and then a second pass to do the real compile - which may
+use a bit less than the predicted amount of store. The idea is that this is
+going to turn out faster because the first pass is degenerate and the second
+pass can just store stuff straight into the vector. It does make the compiling
+functions bigger, of course, but they have got quite big anyway to handle all
+the Perl stuff.
+
+The compiled form of a pattern is a vector of bytes, containing items of
+variable length. The first byte in an item is an opcode, and the length of the
+item is either implicit in the opcode or contained in the data bytes which
+follow it. A list of all the opcodes follows:
+
+Opcodes with no following data
+------------------------------
+
+These items are all just one byte long
+
+ OP_END end of pattern
+ OP_ANY match any character
+ OP_SOD match start of data: \A
+ OP_CIRC ^ (start of data, or after \n in multiline)
+ OP_NOT_WORD_BOUNDARY \W
+ OP_WORD_BOUNDARY \w
+ OP_EODN match end of data or \n at end: \Z
+ OP_EOD match end of data: \z
+ OP_DOLL $ (end of data, or before \n in multiline)
+ OP_RECURSE match the pattern recursively
+
+
+Repeating single characters
+---------------------------
+
+The common repeats (*, +, ?) when applied to a single character appear as
+two-byte items using the following opcodes:
+
+ OP_MAXSTAR
+ OP_MINSTAR
+ OP_ONCESTAR
+ OP_MAXPLUS
+ OP_MINPLUS
+ OP_ONCEPLUS
+ OP_MAXQUERY
+ OP_MINQUERY
+ OP_ONCEQUERY
+
+Those with "MIN" in their name are the minimizing versions; those with ONCE
+instead are maximizing but do not do backtracking. Each is followed by
+the character that is to be repeated. Other repeats make use of
+
+ OP_MAXUPTO
+ OP_MINUPTO
+ OP_ONCEUPTO
+ OP_EXACT
+
+which are followed by a two-byte count (most significant first) and the
+repeated character. OP_*UPTO matches from 0 to the given number. A repeat with a
+non-zero minimum and a fixed maximum is coded as an OP_EXACT followed by an
+OP_*UPTO.
+
+
+Character types
+---------------
+
+Things like \d, both repeated and not, are done exactly like repeated characters,
+except that instead of a character, the opcode for the type is stored in the data
+byte: 0 matches no character (all characters when negated), 1 matches digits,
+2 matches whitespace, 3 matches word characters. The opcodes are:
+
+ OP_TYPE OP_TYPENOT
+ OP_TYPE_MAXSTAR OP_TYPENOT_MAXSTAR
+ OP_TYPE_MINSTAR OP_TYPENOT_MINSTAR
+ OP_TYPE_ONCESTAR OP_TYPENOT_ONCESTAR
+ OP_TYPE_MAXPLUS OP_TYPENOT_MAXPLUS
+ OP_TYPE_MINPLUS OP_TYPENOT_MINPLUS
+ OP_TYPE_ONCEPLUS OP_TYPENOT_ONCEPLUS
+ OP_TYPE_MAXQUERY OP_TYPENOT_MAXQUERY
+ OP_TYPE_MINQUERY OP_TYPENOT_MINQUERY
+ OP_TYPE_ONCEQUERY OP_TYPENOT_ONCEQUERY
+ OP_TYPE_MAXUPTO OP_TYPENOT_MAXUPTO
+ OP_TYPE_MINUPTO OP_TYPENOT_MINUPTO
+ OP_TYPE_ONCEUPTO OP_TYPENOT_ONCEUPTO
+ OP_TYPE_EXACT OP_TYPENOT_EXACT
+
+The opcodes on the first line are the two that do not handle backtracking nor
+repeats.
+
+Matching a character string
+---------------------------
+
+The OP_CHARS opcode is followed by a one-byte count and then that number of
+characters. If there are more than 255 characters in sequence, successive
+instances of OP_CHARS are used.
+
+
+Character classes
+-----------------
+
+OP_CLASS is used for a character class, provided there are at least two
+characters in the class. If there is only one character, OP_CHARS is used for a
+positive class, and OP_NOT for a negative one (that is, for something like
+[^a]). Another set of repeating opcodes (OP_NOT_MAXSTAR etc.) are used for a
+repeated, negated, single-character class. The normal ones (OP_MAXSTAR etc.)
+are used for a repeated positive single-character class.
+
+OP_CLASS is followed by a 32-byte bit map containing a 1 bit for every
+character that is acceptable. The bits are counted from the least significant
+end of each byte.
+
+
+Back references
+---------------
+
+OP_REF is followed by two bytes containing the reference number.
+
+
+Repeating character classes and back references
+-----------------------------------------------
+
+This applies to OP_CLASS and OP_REF. For generic ranges (not + * ?) we use a
+single "RANGE" opcode instead of the UPTO+EXACT combination: these are
+
+ OP_CL_MAXRANGE
+ OP_CL_MINRANGE
+ OP_CL_ONCERANGE
+ OP_REF_MAXRANGE
+ OP_REF_MINRANGE
+ OP_REF_ONCERANGE
+
+and are followed by four bytes of data, comprising the minimum and maximum
+repeat counts.
+
+Single-character classes are handled specially (see above).
+
+
+Brackets and alternation
+------------------------
+
+A pair of non-capturing (round) brackets is wrapped round each expression at
+compile time, so alternation always happens in the context of brackets.
+
+Non-capturing brackets use the opcode OP_BRA, while capturing brackets use
+OP_BRA+1, OP_BRA+2, etc. [Note for North Americans: "bracket" to some English
+speakers, including myself, can be round, square, curly, or pointy. Hence this
+usage.]
+
+Originally PCRE was limited to 99 capturing brackets (so as not to use up all
+the opcodes). From release 3.5, there is no limit. What happens is that the
+first ones, up to EXTRACT_BASIC_MAX are handled with separate opcodes, as
+above. If there are more, the opcode is set to EXTRACT_BASIC_MAX+1, and the
+first operation in the bracket is OP_BRANUMBER, followed by a 2-byte bracket
+number. This opcode is ignored while matching, but is fished out when handling
+the bracket itself. (They could have all been done like this, but I was making
+minimal changes.)
+
+A bracket opcode is followed by two bytes which give the offset to the next
+alternative OP_ALT or, if there aren't any branches, to the matching KET
+opcode. Each OP_ALT is followed by two bytes giving the offset to the next one,
+or to the KET opcode.
+
+OP_KET is used for subpatterns that do not repeat indefinitely, while
+OP_KET_MINSTAR, OP_KET_MAXSTAR and OP_KET_ONCESTAR are used for indefinite
+repetitions, minimally or maximally respectively. All three are followed by
+two bytes giving (as a positive number) the offset back to the matching BRA
+opcode.
+
+If a subpattern is quantified such that it is permitted to match zero times, it
+is preceded by one of OP_BRAZERO or OP_BRAMINZERO. These are single-byte
+opcodes which tell the matcher that skipping this subpattern entirely is a
+valid branch.
+
+A subpattern with an indefinite maximum repetition is replicated in the
+compiled data its minimum number of times (or once with a BRAZERO if the
+minimum is zero), with the final copy terminating with a KETRMIN or KETRMAX as
+appropriate.
+
+A subpattern with a bounded maximum repetition is replicated in a nested
+fashion up to the maximum number of times, with BRAZERO or BRAMINZERO before
+each replication after the minimum, so that, for example, (abc){2,5} is
+compiled as (abc)(abc)((abc)((abc)(abc)?)?)?. The 99 and 200 bracket limits do
+not apply to these internally generated brackets.
+
+
+Assertions
+----------
+
+Forward assertions are just like other subpatterns, but starting with one of
+the opcodes OP_ASSERT or OP_ASSERT_NOT. Backward assertions use the opcodes
+OP_ASSERTBACK and OP_ASSERTBACK_NOT, and the first opcode inside the assertion
+is OP_REVERSE, followed by a two byte count of the number of characters to move
+back the pointer in the subject string. A separate count is present in each
+alternative of a lookbehind assertion, allowing them to have different
+fixed lengths.
+
+
+Once-only subpatterns
+---------------------
+
+These are also just like other subpatterns, but they start with the opcode
+OP_ONCE.
+
+
+Conditional subpatterns
+-----------------------
+
+These are like other subpatterns, but they start with the opcode OP_COND. If
+the condition is a back reference, this is stored at the start of the
+subpattern using the opcode OP_CREF followed by two bytes containing the
+reference number. Otherwise, a conditional subpattern will always start with
+one of the assertions.
+
+
+Changing options
+----------------
+
+If any of the /i, /m, or /s options are changed within a parenthesized group,
+an OP_OPT opcode is compiled, followed by one byte containing the new settings
+of these flags. If there are several alternatives in a group, there is an
+occurrence of OP_OPT at the start of all those following the first options
+change, to set appropriate options for the start of the alternative.
+Immediately after the end of the group there is another such item to reset the
+flags to their previous values. Other changes of flag within the pattern can be
+handled entirely at compile time, and so do not cause anything to be put into
+the compiled data.
+
+
+Character tables
+----------------
+
+PCRE uses four tables for manipulating and identifying characters. The final
+argument of the pcre_*compile*() functions is a pointer to a block of memory
+containing the concatenated tables. A call to pcre_maketables() can be used to
+generate a set of tables in the current locale. If the final argument for
+pcre_*_compile*() is passed as NULL, a set of default tables that is built into
+the binary is used.
+
+The first two 256-byte tables provide lower casing and case flipping functions,
+respectively. The next table consists of many 32-byte bit maps which identify
+digits, "word" characters, white space, and so on. These are used when
+building 32-byte bit maps that represent character classes.
+
+The final 256-byte table has bits indicating various character types, as
+follows:
+
+ 1 newline
+ 2 decimal digit
+ 4 white space character
+ 8 alphanumeric or '_'
+ 16 letter
+ 32 hexadecimal digit
+ 128 regular expression metacharacter or binary zero
+
+You should not alter the set of characters that contain the 128 bit, as that
+will cause PCRE to malfunction.
+
+Philip Hazel
+October 2001
+
+modified by
+Paolo Bonzini
+January 2002
diff --git a/pcre/internal.h b/pcre/internal.h
new file mode 100644
index 0000000..5cf3d3c
--- /dev/null
+++ b/pcre/internal.h
@@ -0,0 +1,447 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+
+/* This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+#ifndef PCRE_INTERNAL_H
+#define PCRE_INTERNAL_H
+
+/* This header contains definitions that are shared between the different
+ modules, but which are not relevant to the outside. */
+
+/* Get the definitions provided by running "configure" */
+
+#include "config.h"
+
+/* #define DEBUG */
+
+/* Standard C headers plus the external interface definition */
+
+#include "basicdefs.h"
+#include
+#include
+#include
+
+#ifdef HAVE_STDDEF_H
+# include
+#endif
+#ifdef STDC_HEADERS
+# include
+#endif
+
+#ifdef HAVE_STRING_H
+# include
+#else
+# include
+#endif
+#ifdef HAVE_MEMORY_H
+# include
+#endif
+
+#ifndef HAVE_STRCHR
+# define strchr index
+# define strrchr rindex
+#endif
+
+#include "pcre.h"
+
+#ifdef HAVE_LIMITS_H
+#include
+#else
+#define INT_MAX ((1L<<30)-1+(1L<<30))
+#define INT_MIN (-(1L<<30)-(1L<<30))
+#endif
+
+#ifndef HAVE_MEMSET
+#define memset(s, better_be_zero, n) (better_be_zero ? abort() : bzero(s, n))
+#endif
+
+/* In case there is no definition of offsetof() provided - though any proper
+ Standard C system should have one. */
+
+#ifndef offsetof
+#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
+#endif
+
+/* These are the public options that can change during matching. */
+
+#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
+
+/* Private options flags start at the most significant end of the four bytes,
+ but skip the top bit so we can use ints for convenience without getting tangled
+ with negative values. The public options defined in pcre.h start at the least
+ significant end. Make sure they don't overlap, though now that we have expanded
+ to four bytes there is plenty of space. */
+
+#define PCRE_FIRSTSET 0x40000000 /* first_char is set */
+#define PCRE_REQCHSET 0x20000000 /* req_char is set */
+#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
+#define PCRE_INGROUP 0x08000000 /* compiling inside a group */
+#define PCRE_ICHANGED 0x04000000 /* i option changes within regex */
+
+/* Options for the "extra" block produced by pcre_study(). */
+
+#define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists */
+#define PCRE_STUDY_BM 0x02 /* a Boyer-Moore map exists */
+
+/* Masks for identifying the public options which are permitted at compile
+ time, run time or study time, respectively. */
+
+#define PUBLIC_OPTIONS \
+ (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
+ PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY| \
+ PCRE_ENGLISH_ERRORS)
+
+#define PUBLIC_EXEC_OPTIONS \
+ (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY)
+
+#define PUBLIC_STUDY_OPTIONS \
+ (PCRE_STUDY_NO_PRUNE|PCRE_STUDY_NO_START)
+
+/* Magic number to provide a small check against being handed junk. */
+
+#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
+
+/* Miscellaneous definitions */
+
+typedef int BOOL;
+
+#define FALSE 0
+#define TRUE 1
+
+/* These are escaped items that aren't just an encoding of a particular data
+ value such as \n. They must have non-zero values, as check_escape() returns
+ their negation. Also, they must appear in the same order as in the opcode
+ definitions below, up to ESC_z. The final one must be ESC_REF as subsequent
+ values are used for \1, \2, \3, etc. */
+
+enum
+ {
+ ESC_LESS = 1, ESC_GREATER,
+ ESC_G, ESC_B, ESC_b,
+ ESC_A, ESC_Z, ESC_z,
+ ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w,
+ ESC_FIRST_CONSUME = ESC_D,
+ ESC_LAST_CONSUME = ESC_w,
+ ESC_REF,
+ };
+
+enum
+ {
+ KIND_MAX, KIND_MIN, KIND_ONCE
+ };
+
+/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
+ that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
+ OP_EOD must correspond in order to the list of escapes immediately above. */
+
+enum
+ {
+ OP_END, /* End of pattern */
+
+ /* Values corresponding to backslashed assertions */
+
+ OP_BEG_WORD, /* \< */
+ OP_END_WORD, /* \> */
+ OP_ANCHOR_MATCH, /* \G */
+ OP_NOT_WORD_BOUNDARY, /* \B */
+ OP_WORD_BOUNDARY, /* \b */
+ OP_SOD, /* Start of data: \A */
+ OP_EODN, /* End of data or \n at end of data: \Z. */
+ OP_EOD, /* End of data: \z */
+
+ OP_OPT, /* Set runtime options */
+ OP_CIRC, /* Start of line - varies with multiline switch */
+ OP_DOLL, /* End of line - varies with multiline switch */
+ OP_ANY, /* Match any character */
+
+ OP_CHARS, /* Match string of characters */
+ OP_MAXSTAR, /* The maximizing and minimizing versions of */
+ OP_MINSTAR, /* all these opcodes must come in triples, with */
+ OP_ONCESTAR, /* the minimizing one second and the */
+ OP_MAXPLUS, /* no-backtracking one third. */
+ OP_MINPLUS, /* This first set applies to single characters */
+ OP_ONCEPLUS,
+ OP_MAXQUERY,
+ OP_MINQUERY,
+ OP_ONCEQUERY,
+ OP_MAXUPTO, /* From 0 to n matches */
+ OP_MINUPTO,
+ OP_ONCEUPTO,
+ OP_EXACT,
+
+ OP_NOT, /* Match anything but the following char */
+ OP_NOT_MAXSTAR, /* The maximizing and minimizing versions of */
+ OP_NOT_MINSTAR, /* all these opcodes must come in triples, with */
+ OP_NOT_ONCESTAR, /* the minimizing one second and the */
+ OP_NOT_MAXPLUS, /* no-backtracking one third. */
+ OP_NOT_MINPLUS, /* This set applies to "not" single characters */
+ OP_NOT_ONCEPLUS,
+ OP_NOT_MAXQUERY,
+ OP_NOT_MINQUERY,
+ OP_NOT_ONCEQUERY,
+ OP_NOT_MAXUPTO, /* From 0 to n matches */
+ OP_NOT_MINUPTO,
+ OP_NOT_ONCEUPTO,
+ OP_NOTEXACT, /* Exactly n matches */
+
+ OP_TYPE,
+ OP_TYPE_MAXSTAR, /* The maximizing and minimizing versions of */
+ OP_TYPE_MINSTAR, /* all these opcodes must come in triples, with */
+ OP_TYPE_ONCESTAR, /* the minimizing one second and the */
+ OP_TYPE_MAXPLUS, /* no-backtracking one third. These codes must */
+ OP_TYPE_MINPLUS, /* be in exactly the same order as those above. */
+ OP_TYPE_ONCEPLUS,
+ OP_TYPE_MAXQUERY, /* This set applies to character types such as \d */
+ OP_TYPE_MINQUERY,
+ OP_TYPE_ONCEQUERY,
+ OP_TYPE_MAXUPTO, /* From 0 to n matches */
+ OP_TYPE_MINUPTO,
+ OP_TYPE_ONCEUPTO,
+ OP_TYPEEXACT, /* Exactly n matches */
+
+ OP_TYPENOT,
+ OP_TYPENOT_MAXSTAR, /* The maximizing and minimizing versions of */
+ OP_TYPENOT_MINSTAR, /* all these opcodes must come in triples, with */
+ OP_TYPENOT_ONCESTAR, /* the minimizing one second and the */
+ OP_TYPENOT_MAXPLUS, /* no-backtracking one third. These codes must */
+ OP_TYPENOT_MINPLUS, /* be in exactly the same order as those above. */
+ OP_TYPENOT_ONCEPLUS,
+ OP_TYPENOT_MAXQUERY, /* This set applies to character types such as \D */
+ OP_TYPENOT_MINQUERY,
+ OP_TYPENOT_ONCEQUERY,
+ OP_TYPENOT_MAXUPTO, /* From 0 to n matches */
+ OP_TYPENOT_MINUPTO,
+ OP_TYPENOT_ONCEUPTO,
+ OP_TYPENOTEXACT, /* Exactly n matches */
+
+ OP_CLASS, /* Match a character class */
+ OP_CL_MAXSTAR, /* The maximizing and minimizing versions of */
+ OP_CL_MINSTAR, /* all these opcodes must come in pairs, with */
+ OP_CL_ONCESTAR, /* the minimizing one second and the */
+ OP_CL_MAXPLUS, /* no-backtracking one third. These codes must */
+ OP_CL_MINPLUS, /* be in exactly the same order as those above. */
+ OP_CL_ONCEPLUS,
+ OP_CL_MAXQUERY, /* These are for character classes */
+ OP_CL_MINQUERY,
+ OP_CL_ONCEQUERY,
+ OP_CL_MAXRANGE, /* These are different to the three seta above. */
+ OP_CL_MINRANGE,
+ OP_CL_ONCERANGE,
+
+ OP_REF, /* Match a back reference */
+ OP_REF_MAXSTAR, /* The maximizing and minimizing versions of */
+ OP_REF_MINSTAR, /* all these opcodes must come in pairs, with */
+ OP_REF_ONCESTAR, /* the minimizing one second and the */
+ OP_REF_MAXPLUS, /* no-backtracking one third. These codes must */
+ OP_REF_MINPLUS, /* be in exactly the same order as those above. */
+ OP_REF_ONCEPLUS,
+ OP_REF_MAXQUERY, /* These are for character classes */
+ OP_REF_MINQUERY,
+ OP_REF_ONCEQUERY,
+ OP_REF_MAXRANGE, /* These are different to the three seta above. */
+ OP_REF_MINRANGE,
+ OP_REF_ONCERANGE,
+
+ OP_RECURSE, /* Match this pattern recursively */
+
+ OP_ALT, /* Start of alternation */
+ OP_KET, /* End of group that doesn't have an unbounded repeat */
+ OP_KET_MAXSTAR, /* These three must remain together and in this */
+ OP_KET_MINSTAR, /* order. They are for groups the repeat for ever. */
+ OP_KET_ONCESTAR,
+
+ /* The assertions must come before ONCE and COND */
+
+ OP_ASSERT, /* Positive lookahead */
+ OP_ASSERT_NOT, /* Negative lookahead */
+ OP_ASSERTBACK, /* Positive lookbehind */
+ OP_ASSERTBACK_NOT, /* Negative lookbehind */
+ OP_REVERSE, /* Move pointer back - used in lookbehind assertions */
+
+ /* ONCE and COND must come after the assertions, with ONCE first, as there's
+ a test for >= ONCE for a subpattern that isn't an assertion. */
+
+ OP_ONCE, /* Once matched, don't back up into the subpattern */
+ OP_COND, /* Conditional group */
+ OP_CREF, /* Used to hold an extraction string number (cond ref) */
+
+ OP_BRAZERO, /* These two must remain together and in this */
+ OP_BRAMINZERO, /* order. */
+
+ OP_BRANUMBER, /* Used for extracting brackets whose number is greater
+ than can fit into an opcode. */
+
+ OP_BRA /* This and greater values are used for brackets that
+ extract substrings up to a basic limit. After that,
+ use is made of OP_BRANUMBER. */
+ };
+
+/* The highest extraction number. This is limited by the number of opcodes
+ left after OP_BRA, i.e. 255 - OP_BRA. We actually set it somewhat lower
+ to leave room for additional opcodes.. */
+
+#define EXTRACT_BASIC_MAX 150
+
+/* The texts of compile-time error messages are defined as macros here so that
+ they can be accessed by the POSIX wrapper and converted into error codes. Yes,
+ I could have used error codes in the first place, but didn't feel like changing
+ just to accommodate the POSIX wrapper. */
+
+
+/* All character handling must be done as unsigned characters. Otherwise there
+ are problems with top-bit-set characters and functions such as isspace().
+ However, we leave the interface to the outside world as char *, because that
+ should make things easier for callers. We define a short type for unsigned char
+ to save lots of typing. I tried "uchar", but it causes problems on Digital
+ Unix, where it is defined in sys/types, so use "uschar" instead. */
+
+typedef unsigned char uschar;
+
+typedef uschar bitset[32];
+
+/* The real format of the start of the pcre block; the actual code vector
+ runs on as long as necessary after the end. */
+
+struct pcre
+ {
+ unsigned long int magic_number;
+ size_t size;
+ ssize_t max_match_size;
+ const unsigned char *tables;
+ unsigned long int options;
+ unsigned short int top_bracket;
+ unsigned short int top_backref;
+ uschar first_char;
+ uschar req_char;
+ uschar code[1];
+ };
+
+/* The real format of the extra block returned by pcre_study(). */
+
+struct pcre_extra
+ {
+ uschar options;
+ union {
+ bitset start_bits;
+ uschar bmtable[257];
+ } data;
+ };
+
+
+/* Structure for passing "static" information around between the functions
+ doing the compiling, so that they are thread-safe. */
+
+typedef struct compile_data
+ {
+ const uschar *lcc; /* Points to lower casing table */
+ const uschar *fcc; /* Points to case-flipping table */
+ const uschar *cbits; /* Points to character type table */
+ const uschar *ctypes; /* Points to table of type maps */
+ const uschar *end; /* Points to last valid byte */
+ ssize_t max_match_size;
+ }
+compile_data;
+
+/* Structure for passing "static" information around between the functions
+ doing the matching, so that they are thread-safe. */
+
+typedef struct match_data
+ {
+ int errorcode; /* As it says */
+ int *offset_vector; /* Offset vector */
+ int offset_end; /* One past the end */
+ int offset_max; /* The maximum usable for return data */
+ const uschar *lcc; /* Points to lower casing table */
+ const uschar *ctypes; /* Points to table of type maps */
+ BOOL offset_overflow; /* Set if too many extractions */
+ BOOL notbol; /* NOTBOL flag */
+ BOOL noteol; /* NOTEOL flag */
+ BOOL utf8; /* UTF8 flag */
+ BOOL endonly; /* Dollar not before final \n */
+ BOOL notempty; /* Empty string match not wanted */
+ const uschar *start_pattern; /* For use when recursing */
+ const uschar *start_subject; /* Start of the subject string */
+ const uschar *end_subject; /* End of the subject string */
+ const uschar *first_start; /* Part of subject considered by preg_exec */
+ const uschar *start_match; /* Start of this match attempt */
+ const uschar *end_match_ptr; /* Subject position at end match */
+ int end_offset_top; /* Highwater mark at end of match */
+ }
+match_data;
+
+/* Bit definitions for entries in the pcre_ctypes table. */
+
+#define ctype_newline 0x01
+#define ctype_digit 0x02 /* must follow the other in the escapes above */
+#define ctype_space 0x04
+#define ctype_word 0x08 /* alphameric or '_' */
+#define ctype_letter 0x10
+#define ctype_xdigit 0x20
+#define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */
+
+/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
+ of bits for a class map. Some classes are built by combining these tables. */
+
+#define cbit_xdigit 0 /* [:xdigit:] */
+#define cbit_digit 32 /* [:digit:] */
+#define cbit_space 64 /* [:space:] */
+#define cbit_word 96 /* [:word:] */
+#define cbit_upper 128 /* [:upper:] */
+#define cbit_lower 160 /* [:lower:] */
+#define cbit_graph 192 /* [:graph:] */
+#define cbit_print 224 /* [:print:] */
+#define cbit_punct 256 /* [:punct:] */
+#define cbit_cntrl 288 /* [:cntrl:] */
+#define cbit_blank 320 /* [:blank:] */
+#define cbit_length 352 /* Length of the cbits table */
+
+/* Offsets of the various tables from the base tables pointer, and
+ total length. */
+
+#define lcc_offset 0
+#define fcc_offset 256
+#define cbits_offset 512
+#define ctypes_offset (cbits_offset + cbit_length)
+#define tables_length (ctypes_offset + 256)
+
+#ifdef __STDC__
+#define __PCRE_PROTO(a) a
+#else
+#define __PCRE_PROTO(a) ()
+#endif
+
+extern void pcre_debug __PCRE_PROTO ((pcre *));
+extern const char *pcre_estrings[];
+extern const char *pcre_OP_names[];
+
+#endif
diff --git a/pcre/pcre.h b/pcre/pcre.h
new file mode 100644
index 0000000..8860629
--- /dev/null
+++ b/pcre/pcre.h
@@ -0,0 +1,119 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/* Copyright (c) 1997-2000 University of Cambridge */
+
+#ifndef _PCRE_H
+#define _PCRE_H
+
+/* Have to include stdlib.h in order to ensure that size_t is defined;
+ it is needed here for malloc. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef STDC_HEADERS
+#include
+#endif
+#ifdef BOOTSTRAP
+#include
+#endif
+
+/* Allow for C++ users */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef __STDC__
+#define __PCRE_PROTO(a) a
+#else
+#define __PCRE_PROTO(a) ()
+#endif
+
+/* Options */
+
+#define PCRE_CASELESS 0x0001
+#define PCRE_MULTILINE 0x0002
+#define PCRE_DOTALL 0x0004
+#define PCRE_EXTENDED 0x0008
+#define PCRE_ANCHORED 0x0010
+#define PCRE_DOLLAR_ENDONLY 0x0020
+#define PCRE_EXTRA 0x0040
+#define PCRE_NOTBOL 0x0080
+#define PCRE_NOTEOL 0x0100
+#define PCRE_UNGREEDY 0x0200
+#define PCRE_NOTEMPTY 0x0400
+#define PCRE_ENGLISH_ERRORS 0x0800
+#define PCRE_STUDY_NO_PRUNE 0x04
+#define PCRE_STUDY_NO_START 0x08
+
+/* Exec-time and get-time error codes */
+
+#define PCRE_ERROR_NOMATCH (-1)
+#define PCRE_ERROR_NULL (-2)
+#define PCRE_ERROR_BADOPTION (-3)
+#define PCRE_ERROR_BADMAGIC (-4)
+#define PCRE_ERROR_UNKNOWN_NODE (-5)
+#define PCRE_ERROR_NOMEMORY (-6)
+#define PCRE_ERROR_NOSUBSTRING (-7)
+
+/* Request types for pcre_fullinfo() */
+
+#define PCRE_INFO_OPTIONS 0
+#define PCRE_INFO_SIZE 1
+#define PCRE_INFO_CAPTURECOUNT 2
+#define PCRE_INFO_BACKREFMAX 3
+#define PCRE_INFO_FIRSTCHAR 4
+#define PCRE_INFO_FIRSTTABLE 5
+#define PCRE_INFO_LASTLITERAL 6
+#define PCRE_INFO_BMTABLE 7
+
+/* Types */
+
+struct pcre;
+struct pcre_extra;
+typedef struct pcre pcre;
+typedef struct pcre_extra pcre_extra;
+
+/* Store get and free functions. These can be set to alternative malloc/free
+ functions if required. */
+
+extern void *(*pcre_malloc) (size_t);
+extern void (*pcre_free) (void *);
+
+/* Functions */
+
+extern pcre *pcre_posix_compile __PCRE_PROTO ((const char *, int, const char **,
+ int *, const unsigned char *));
+extern pcre *pcre_compile __PCRE_PROTO ((const char *, int, const char **,
+ int *, const unsigned char *));
+extern pcre *pcre_posix_compile_nuls __PCRE_PROTO ((const char *, int, int,
+ const char **, int *,
+ const unsigned char *));
+extern pcre *pcre_compile_nuls __PCRE_PROTO ((const char *, int, int,
+ const char **, int *,
+ const unsigned char *));
+extern int pcre_copy_substring __PCRE_PROTO ((const char *, int *, int, int,
+ char *, int));
+extern int pcre_exec __PCRE_PROTO ((const pcre *, const pcre_extra *,
+ const char *, int, int, int, int *, int));
+extern void pcre_free_substring __PCRE_PROTO ((const char *));
+extern void pcre_free_substring_list __PCRE_PROTO ((const char **));
+extern int pcre_get_substring __PCRE_PROTO ((const char *, int *, int, int,
+ const char **));
+extern int pcre_get_substring_list __PCRE_PROTO ((const char *, int *, int,
+ const char ***));
+extern int pcre_info __PCRE_PROTO ((const pcre *, const pcre_extra *, int,
+ void *));
+extern const unsigned char *pcre_maketables __PCRE_PROTO ((void));
+extern pcre_extra *pcre_study __PCRE_PROTO ((const pcre *, int, const char **));
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+#undef __PCRE_PROTO
+
+#endif
diff --git a/pcre/pcregrep.c b/pcre/pcregrep.c
new file mode 100644
index 0000000..7619ef8
--- /dev/null
+++ b/pcre/pcregrep.c
@@ -0,0 +1,282 @@
+/*************************************************
+* pcregrep program *
+*************************************************/
+
+/* This is a grep program that uses the PCRE regular expression library to do
+ its pattern matching. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#ifdef STDC_HEADERS
+#include
+#include
+#endif
+#include
+#include "pcre.h"
+
+#ifdef HAVE_LOCALE_H
+#include
+#endif
+
+#ifdef ENABLE_NLS
+# include
+#else
+# define gettext(s) (s)
+#endif
+#define _(s) gettext(s)
+
+#define FALSE 0
+#define TRUE 1
+
+typedef int BOOL;
+
+
+
+/*************************************************
+* Global variables *
+*************************************************/
+
+static pcre *pattern;
+static pcre_extra *hints;
+
+static BOOL count_only = FALSE;
+static BOOL filenames_only = FALSE;
+static BOOL invert = FALSE;
+static BOOL number = FALSE;
+static BOOL silent = FALSE;
+static BOOL whole_lines = FALSE;
+
+
+
+
+/*************************************************
+* Grep an individual file *
+*************************************************/
+
+static int
+pcregrep (in, name)
+ FILE *in;
+ char *name;
+{
+ int rc = 1;
+ int linenumber = 0;
+ int count = 0;
+ int offsets[99];
+ char buffer[BUFSIZ];
+
+ while (fgets (buffer, sizeof (buffer), in) != NULL)
+ {
+ BOOL match;
+ int length = (int) strlen (buffer);
+ if (length > 0 && buffer[length - 1] == '\n')
+ buffer[--length] = 0;
+ linenumber++;
+
+ match = pcre_exec (pattern, hints, buffer, length, 0, 0, offsets, 99) >= 0;
+ if (match && whole_lines && offsets[1] != length)
+ match = FALSE;
+
+ if (match != invert)
+ {
+ if (count_only)
+ count++;
+
+ else if (filenames_only)
+ {
+ printf("%s\n", (name == NULL) ? "" : name);
+ return 0;
+ }
+
+ else if (silent)
+ return 0;
+
+ else
+ {
+ if (name != NULL)
+ printf("%s:", name);
+ if (number)
+ printf("%d:", linenumber);
+ printf("%s\n", buffer);
+ }
+
+ rc = 0;
+ }
+ }
+
+ if (count_only)
+ {
+ if (name != NULL)
+ printf("%s:", name);
+ printf("%d\n", count);
+ }
+
+ return rc;
+}
+
+
+
+
+/*************************************************
+* Usage function *
+*************************************************/
+
+static int
+usage (rc)
+ int rc;
+{
+ fprintf (stderr, _("Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"));
+ return rc;
+}
+
+
+
+
+/*************************************************
+* Main program *
+*************************************************/
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int i;
+ int rc = 1;
+ int options = 0;
+ int errptr;
+ char kind;
+ const char *error;
+ BOOL filenames = TRUE;
+
+#if HAVE_SETLOCALE
+ /* Set locale according to user's wishes. */
+ setlocale (LC_ALL, "");
+#endif
+
+#if ENABLE_NLS
+ /* Tell program which translations to use and where to find. */
+ /* bindtextdomain (PACKAGE, LOCALEDIR); */
+ textdomain (PACKAGE);
+#endif
+
+ /* Process the options */
+ kind = 'p';
+ for (i = 1; i < argc; i++)
+ {
+ char *s;
+ if (argv[i][0] != '-')
+ break;
+ s = argv[i] + 1;
+ while (*s != 0)
+ {
+ switch (*s++)
+ {
+ case 'c':
+ count_only = TRUE;
+ break;
+ case 'b':
+ kind = 'b';
+ break;
+ case 'e':
+ kind = 'e';
+ break;
+ case 'p':
+ kind = 'p';
+ break;
+ case 'h':
+ filenames = FALSE;
+ break;
+ case 'i':
+ options |= PCRE_CASELESS;
+ break;
+ case 'l':
+ filenames_only = TRUE;
+ case 'n':
+ number = TRUE;
+ break;
+ case 's':
+ silent = TRUE;
+ break;
+ case 'v':
+ invert = TRUE;
+ break;
+ case 'x':
+ whole_lines = TRUE;
+ options |= PCRE_ANCHORED;
+ break;
+
+ default:
+ fprintf (stderr, _("pcregrep: unknown option %c\n"), s[-1]);
+ return usage (2);
+ }
+ }
+ }
+
+ /* There must be at least a regexp argument */
+ if (i >= argc)
+ return usage (0);
+
+ /* Compile the regular expression. */
+ switch (kind)
+ {
+ case 'b':
+ pattern = pcre_posix_compile (argv[i++], options, &error, &errptr, NULL);
+ break;
+ case 'e':
+ pattern = pcre_posix_compile (argv[i++], options | PCRE_EXTENDED,
+ &error, &errptr, NULL);
+ break;
+ case 'p':
+ pattern = pcre_compile (argv[i++], options, &error, &errptr, NULL);
+ break;
+ }
+
+ if (pattern == NULL)
+ {
+ fprintf (stderr, _("pcregrep: error in regex at offset %d: %s\n"),
+ errptr, error);
+ return 2;
+ }
+
+ /* Study the regular expression, as we will be running it may times */
+ hints = pcre_study (pattern, 0, &error);
+ if (error != NULL)
+ {
+ fprintf (stderr, _("pcregrep: error while studing regex: %s\n"), error);
+ return 2;
+ }
+
+ /* If there are no further arguments, do the business on stdin and exit */
+ if (i >= argc)
+ return pcregrep (stdin, NULL);
+
+ /* Otherwise, work through the remaining arguments as files. If there is only
+ one, don't give its name on the output. */
+ if (i == argc - 1)
+ filenames = FALSE;
+ if (filenames_only)
+ filenames = TRUE;
+
+ for (; i < argc; i++)
+ {
+ FILE *in = fopen (argv[i], "r");
+ if (in == NULL)
+ {
+ fprintf (stderr, _("pcregrep: failed to open %s: %s\n"),
+ argv[i], strerror (errno));
+ rc = 2;
+ }
+ else
+ {
+ int frc = pcregrep (in, filenames ? argv[i] : NULL);
+ if (frc == 0 && rc == 1)
+ rc = 0;
+ fclose (in);
+ }
+ }
+
+ return rc;
+}
diff --git a/pcre/regcomp.c b/pcre/regcomp.c
new file mode 100644
index 0000000..07c99fb
--- /dev/null
+++ b/pcre/regcomp.c
@@ -0,0 +1,1040 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+
+/* Include the internals header, which itself includes Standard C headers plus
+ the external pcre header. */
+
+#include "internal.h"
+
+/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
+ inline, and there are *still* stupid compilers about that don't like indented
+ pre-processor statements. I suppose it's only been 10 years... */
+
+#ifdef DEBUG
+#define DPRINTF(p) printf p
+#define DFWRITE(p) fwrite p
+#else
+#define DPRINTF(p) /*nothing */
+#define DFWRITE(p) /*nothing */
+#endif
+
+
+
+/* Allow compilation as C++ source code, should anybody want to do that. */
+
+#ifdef __cplusplus
+#define class pcre_class
+#endif
+
+
+
+/* Tables of names of POSIX character classes and their lengths. The list is
+ terminated by a zero length entry. The first three must be alpha, upper, lower,
+ as this is assumed for handling case independence. */
+
+static const char *posix_names[] =
+{
+ "alpha", "lower", "upper",
+ "alnum", "ascii", "cntrl", "digit", "graph",
+ "print", "punct", "space", "word", "xdigit",
+ "blank"
+};
+
+static const uschar posix_name_lengths[] =
+{
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 5, 0
+};
+
+static const int posix_class_maps[] =
+{
+ cbit_lower, cbit_upper, -1, /* alpha */
+ cbit_lower, -1, -1, /* lower */
+ cbit_upper, -1, -1, /* upper */
+ cbit_digit, cbit_lower, cbit_upper, /* alnum */
+ cbit_print, cbit_cntrl, -1, /* ascii */
+ cbit_cntrl, -1, -1, /* cntrl */
+ cbit_digit, -1, -1, /* digit */
+ cbit_graph, -1, -1, /* graph */
+ cbit_print, -1, -1, /* print */
+ cbit_punct, -1, -1, /* punct */
+ cbit_space, -1, -1, /* space */
+ cbit_word, -1, -1, /* word */
+ cbit_xdigit, -1, -1, /* xdigit */
+ cbit_blank, -1, -1 /* blank */
+};
+
+
+
+/*************************************************
+* Check for counted repeat *
+*************************************************/
+
+/* This function is called when a '{' is encountered in a place where it might
+ start a quantifier. It looks ahead to see if it really is a quantifier or not.
+ It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd}
+ where the ddds are digits.
+
+ Arguments:
+ p pointer to the first char after '{'
+ cd pointer to char tables block
+
+ Returns: TRUE or FALSE
+ */
+
+static BOOL
+is_counted_repeat (p, cd)
+ const uschar *p;
+ compile_data *cd;
+{
+ if (p > cd->end)
+ return FALSE;
+ if ((cd->ctypes[*p++] & ctype_digit) == 0)
+ return FALSE;
+ while (p <= cd->end && (cd->ctypes[*p] & ctype_digit) != 0)
+ p++;
+
+ /* Check end of regexp */
+ if (p > cd->end)
+ return FALSE;
+ if (p == cd->end)
+ return (*p == '}');
+
+ /* Not at end of regexp */
+ if (*p == '}')
+ return TRUE;
+ if (*p++ != ',')
+ return FALSE;
+
+ /* Check again for end of regexp */
+ if (p == cd->end)
+ return (*p == '}');
+ if (*p == '}')
+ return TRUE;
+
+ if (p > cd->end)
+ return FALSE;
+ if ((cd->ctypes[*p++] & ctype_digit) == 0)
+ return FALSE;
+ while (p <= cd->end && (cd->ctypes[*p] & ctype_digit) != 0)
+ p++;
+
+ return (p <= cd->end && *p == '}');
+}
+
+
+
+/*************************************************
+* Read repeat counts *
+*************************************************/
+
+/* Read an item of the form {n,m} and return the values. This is called only
+ after is_counted_repeat() has confirmed that a repeat-count quantifier exists,
+ so the syntax is guaranteed to be correct, but we need to check the values.
+
+ Arguments:
+ p pointer to first char after '{'
+ minp pointer to int for min
+ maxp pointer to int for max
+ returned as -1 if no max
+ errorptr points to pointer to error message
+ cd pointer to character tables clock
+
+ Returns: pointer to '}' on success;
+ current ptr on error, with errorptr set
+ */
+
+static const uschar *
+read_repeat_counts (p, minp, maxp, errorptr, cd)
+ const uschar *p;
+ int *minp;
+ int *maxp;
+ const char **errorptr;
+ compile_data *cd;
+{
+ int min = 0;
+ int max = -1;
+
+ while ((cd->ctypes[*p] & ctype_digit) != 0)
+ min = min * 10 + *p++ - '0';
+
+ if (*p == '}')
+ max = min;
+ else
+ {
+ if (*(++p) != '}')
+ {
+ max = 0;
+ while ((cd->ctypes[*p] & ctype_digit) != 0)
+ max = max * 10 + *p++ - '0';
+ if (max < min)
+ {
+ *errorptr = pcre_estrings[4];
+ return p;
+ }
+ }
+ }
+
+ min *= *minp;
+ if (max > 0)
+ max *= *maxp;
+
+ /* Do paranoid checks, then fill in the required variables, and pass back the
+ pointer to the terminating '}'. */
+
+ if (min > 65535 || max > 65535)
+ *errorptr = pcre_estrings[5];
+ else
+ {
+ *minp = min;
+ *maxp = max;
+ }
+
+ return p;
+}
+
+
+
+/*************************************************
+* Find the fixed length of a pattern *
+*************************************************/
+
+/* Scan a pattern and compute the fixed length of subject that will match it,
+ if the length is fixed. This is needed for dealing with backward assertions.
+
+ Arguments:
+ code points to the start of the pattern (the bracket)
+ options the compiling options
+
+ Returns: the fixed length, or -1 if there is no fixed length
+ */
+
+static int
+find_fixedlength (code, options)
+ uschar *code;
+ int options;
+{
+ int length = -1;
+
+ register int branchlength = 0;
+ register uschar *cc = code + 3;
+
+/* Scan along the opcodes for this branch. If we get to the end of the
+ branch, check the length against that of the other branches. */
+
+ for (;;)
+ {
+ int d;
+ register int op = *cc;
+ if (op >= OP_BRA)
+ op = OP_BRA;
+
+ switch (op)
+ {
+ case OP_BRA:
+ case OP_ONCE:
+ case OP_COND:
+ d = find_fixedlength (cc, options);
+ if (d < 0)
+ return -1;
+ branchlength += d;
+ do
+ cc += (cc[1] << 8) + cc[2];
+ while (*cc == OP_ALT);
+ cc += 3;
+ break;
+
+ /* Reached end of a branch; if it's a ket it is the end of a nested
+ call. If it's ALT it is an alternation in a nested call. If it is
+ END it's the end of the outer call. All can be handled by the same code. */
+
+ case OP_ALT:
+ case OP_KET:
+ case OP_KET_MAXSTAR:
+ case OP_KET_MINSTAR:
+ case OP_END:
+ if (length < 0)
+ length = branchlength;
+ else if (length != branchlength)
+ return -1;
+ if (*cc != OP_ALT)
+ return length;
+ cc += 3;
+ branchlength = 0;
+ break;
+
+ /* Skip over assertive subpatterns */
+
+ case OP_ASSERT:
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ do
+ cc += (cc[1] << 8) + cc[2];
+ while (*cc == OP_ALT);
+ cc += 3;
+ break;
+
+ /* Skip over things that don't match chars */
+
+ case OP_REVERSE:
+ case OP_BRANUMBER:
+ case OP_CREF:
+ cc++;
+ /* Fall through */
+
+ case OP_OPT:
+ cc++;
+ /* Fall through */
+
+ case OP_SOD:
+ case OP_EOD:
+ case OP_EODN:
+ case OP_CIRC:
+ case OP_DOLL:
+ case OP_NOT_WORD_BOUNDARY:
+ case OP_WORD_BOUNDARY:
+ case OP_ANCHOR_MATCH:
+ cc++;
+ break;
+
+ /* Handle char strings. */
+
+ case OP_CHARS:
+ branchlength += *(++cc);
+ cc += *cc + 1;
+ break;
+
+ /* Handle exact repetitions */
+
+ case OP_EXACT:
+ case OP_TYPEEXACT:
+ branchlength += (cc[1] << 8) + cc[2];
+ cc += 4;
+ break;
+
+ /* Handle single-char matchers */
+
+ case OP_TYPE:
+ case OP_TYPENOT:
+ branchlength++;
+ cc += 2;
+ break;
+
+ case OP_ANY:
+ branchlength++;
+ cc++;
+ break;
+
+ /* Check a class for variable quantification */
+
+ case OP_CLASS:
+ branchlength++;
+ cc += 33;
+ break;
+
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ return -1;
+
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ cc += 33;
+ if ((cc[1] << 8) + cc[2] != (cc[3] << 8) + cc[4])
+ return -1;
+
+ branchlength += (cc[1] << 8) + cc[2];
+ cc += 4;
+ break;
+
+ /* Anything else is variable length */
+
+ default:
+ return -1;
+ }
+ }
+/* Control never gets here */
+}
+
+
+
+
+/*************************************************
+* Check for POSIX class syntax *
+*************************************************/
+
+/* This function is called when the sequence "[:" or "[." or "[=" is
+ encountered in a character class. It checks whether this is followed by an
+ optional ^ and then a sequence of letters, terminated by a matching ":]" or
+ ".]" or "=]".
+
+ Argument:
+ ptr pointer to the initial [
+ endptr where to return the end pointer
+ cd pointer to compile data
+
+ Returns: TRUE or FALSE
+ */
+
+static BOOL
+check_posix_syntax (ptr, endptr, cd)
+ const uschar *ptr;
+ const uschar **endptr;
+ compile_data *cd;
+{
+ int terminator; /* Don't combine these lines; the Solaris cc */
+ terminator = *(++ptr); /* compiler warns about "non-constant" initializer. */
+ if (*(++ptr) == '^')
+ ptr++;
+
+ /* Use < because we have to look one character ahead */
+ while (ptr < cd->end && (cd->ctypes[*ptr] & ctype_letter) != 0)
+ ptr++;
+ if (ptr < cd->end && *ptr == terminator && ptr[1] == ']')
+ {
+ *endptr = ptr;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+
+
+/*************************************************
+* Check POSIX class name *
+*************************************************/
+
+/* This function is called to check the name given in a POSIX-style class entry
+ such as [:alnum:].
+
+ Arguments:
+ ptr points to the first letter
+ len the length of the name
+
+ Returns: a value representing the name, or -1 if unknown
+ */
+
+static int
+check_posix_name (ptr, len)
+ const uschar *ptr;
+ int len;
+{
+ register int yield = 0;
+ while (posix_name_lengths[yield] != 0)
+ {
+ if (len == posix_name_lengths[yield] &&
+ strncmp ((const char *) ptr, posix_names[yield], len) == 0)
+ return yield;
+ yield++;
+ }
+ return -1;
+}
+
+
+
+
+/*************************************************
+* Compile sequence of alternatives *
+*************************************************/
+
+/* On entry, ptr is pointing past the bracket character, but on return
+ it points to the closing bracket, or vertical bar, or end of string.
+ The code variable is pointing at the byte into which the BRA operator has been
+ stored. If the ims options are changed at the start (for a (?ims: group) or
+ during any branch, we need to insert an OP_OPT item at the start of every
+ following branch to ensure they get set correctly at run time, and also pass
+ the new options into every subsequent branch compile.
+
+ Argument:
+ options the option bits
+ optchanged new ims options to set as if (?ims) were at the start, or -1
+ for no change
+ brackets -> int containing the number of capturing brackets used
+ codeptr -> the address of the current code pointer
+ ptrptr -> the address of the current pattern pointer
+ errorptr -> pointer to error message
+ lookbehind TRUE if this is a lookbehind assertion
+ skipbytes skip this many bytes at start (for OP_COND, OP_BRANUMBER)
+ reqchar -> place to put the last required character, or a negative number
+ countlits -> place to put the shortest literal count of any branch
+ cd points to the data block with tables pointers
+
+ Returns: TRUE on success
+ */
+
+static BOOL
+compile_regex (options, optchanged, brackets, codeptr, ptrptr, errorptr, lookbehind, skipbytes, reqchar, countlits, cd,
+ compile_branch_func)
+ int options;
+ int optchanged;
+ int *brackets;
+ uschar **codeptr;
+ const uschar **ptrptr;
+ const char **errorptr;
+ BOOL lookbehind;
+ int skipbytes;
+ int *reqchar;
+ int *countlits;
+ compile_data *cd;
+ BOOL (*compile_branch_func) (int, int *, uschar **, const uschar **, const char **, int *, int *, int *, compile_data *);
+{
+ const uschar *ptr = *ptrptr;
+ uschar *code = *codeptr;
+ uschar *last_branch = code;
+ uschar *start_bracket = code;
+ uschar *reverse_count = NULL;
+ int oldoptions = options & PCRE_IMS;
+ int branchreqchar, branchcountlits;
+
+ *reqchar = -1;
+ *countlits = INT_MAX;
+ code += 3 + skipbytes;
+
+/* Loop for each alternative branch */
+
+ for (;;)
+ {
+ int length;
+
+ /* Handle change of options */
+
+ if (optchanged >= 0)
+ {
+ *code++ = OP_OPT;
+ *code++ = optchanged;
+ options = (options & ~PCRE_IMS) | optchanged;
+ }
+
+ /* Set up dummy OP_REVERSE if lookbehind assertion */
+
+ if (lookbehind)
+ {
+ *code++ = OP_REVERSE;
+ reverse_count = code;
+ *code++ = 0;
+ *code++ = 0;
+ }
+
+ /* Now compile the branch */
+
+ if (!compile_branch_func (options, brackets, &code, &ptr, errorptr, &optchanged,
+ &branchreqchar, &branchcountlits, cd))
+ {
+ *ptrptr = ptr;
+ return FALSE;
+ }
+
+ /* Fill in the length of the last branch */
+
+ length = code - last_branch;
+ last_branch[1] = length >> 8;
+ last_branch[2] = length & 255;
+
+ /* Save the last required character if all branches have the same; a current
+ value of -1 means unset, while -2 means "previous branch had no last required
+ char". */
+
+ if (*reqchar != -2)
+ {
+ if (branchreqchar >= 0)
+ {
+ if (*reqchar == -1)
+ *reqchar = branchreqchar;
+ else if (*reqchar != branchreqchar)
+ *reqchar = -2;
+ }
+ else
+ *reqchar = -2;
+ }
+
+ /* Keep the shortest literal count */
+
+ if (branchcountlits < *countlits)
+ *countlits = branchcountlits;
+ DPRINTF (("literal count = %d min=%d\n", branchcountlits, *countlits));
+
+ /* If lookbehind, check that this branch matches a fixed-length string,
+ and put the length into the OP_REVERSE item. Temporarily mark the end of
+ the branch with OP_END. */
+
+ if (lookbehind)
+ {
+ *code = OP_END;
+ length = find_fixedlength (last_branch, options);
+ DPRINTF (("fixed length = %d\n", length));
+ if (length < 0)
+ {
+ *errorptr = pcre_estrings[25];
+ *ptrptr = ptr;
+ return FALSE;
+ }
+ reverse_count[0] = (length >> 8);
+ reverse_count[1] = length & 255;
+ }
+
+ /* Reached end of expression, either ')' or end of pattern. Insert a
+ terminating ket and the length of the whole bracketed item, and return,
+ leaving the pointer at the terminating char. If any of the ims options
+ were changed inside the group, compile a resetting op-code following. */
+
+ if (ptr > cd->end || *ptr != '|')
+ {
+ length = code - start_bracket;
+ *code++ = OP_KET;
+ *code++ = length >> 8;
+ *code++ = length & 255;
+ if (optchanged >= 0)
+ {
+ *code++ = OP_OPT;
+ *code++ = oldoptions;
+ }
+ *codeptr = code;
+ *ptrptr = ptr;
+ return TRUE;
+ }
+
+ /* Another branch follows; insert an "or" node and advance the pointer. */
+
+ *code = OP_ALT;
+ last_branch = code;
+ code += 3;
+ ptr++;
+ }
+/* Control never reaches here */
+}
+
+
+
+
+/*************************************************
+* Find first significant op code *
+*************************************************/
+
+/* This is called by several functions that scan a compiled expression looking
+ for a fixed first character, or an anchoring op code etc. It skips over things
+ that do not influence this. For one application, a change of caseless option is
+ important.
+
+ Arguments:
+ code pointer to the start of the group
+ options pointer to external options
+ optbit the option bit whose changing is significant, or
+ zero if none are
+ optstop TRUE to return on option change, otherwise change the options
+ value and continue
+
+ Returns: pointer to the first significant opcode
+ */
+
+static const uschar *
+first_significant_code (code, options, optbit, optstop)
+ const uschar *code;
+ int *options;
+ int optbit;
+ BOOL optstop;
+{
+ for (;;)
+ {
+ switch ((int) *code)
+ {
+ case OP_OPT:
+ if (optbit > 0 && ((int) code[1] & optbit) != (*options & optbit))
+ {
+ if (optstop)
+ return code;
+ *options = (int) code[1];
+ }
+ code += 2;
+ break;
+
+ case OP_CREF:
+ case OP_BRANUMBER:
+ code += 3;
+ break;
+
+ case OP_WORD_BOUNDARY:
+ case OP_NOT_WORD_BOUNDARY:
+ code++;
+ break;
+
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ do
+ code += (code[1] << 8) + code[2];
+ while (*code == OP_ALT);
+ code += 3;
+ break;
+
+ default:
+ return code;
+ }
+ }
+/* Control never reaches here */
+}
+
+
+
+
+/*************************************************
+* Check for anchored expression *
+*************************************************/
+
+/* Try to find out if this is an anchored regular expression. Consider each
+ alternative branch. If they all start with OP_SOD or OP_CIRC, or with a bracket
+ all of whose alternatives start with OP_SOD or OP_CIRC (recurse ad lib), then
+ it's anchored. However, if this is a multiline pattern, then only OP_SOD
+ counts, since OP_CIRC can match in the middle.
+
+ A branch is also implicitly anchored if it starts with .* and DOTALL is set,
+ because that will try the rest of the pattern at all possible matching points,
+ so there is no point trying them again.
+
+ Arguments:
+ code points to start of expression (the bracket)
+ options points to the options setting
+
+ Returns: TRUE or FALSE
+ */
+
+static BOOL
+is_anchored (code, options)
+ register const uschar *code;
+ int *options;
+{
+ do
+ {
+ const uschar *scode = first_significant_code (code + 3, options,
+ PCRE_MULTILINE, FALSE);
+ register int op = *scode;
+ if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
+ {
+ if (!is_anchored (scode, options))
+ return FALSE;
+ }
+ else if ((op == OP_TYPE_MAXSTAR || op == OP_TYPE_MINSTAR) &&
+ (*options & PCRE_DOTALL) != 0)
+ {
+ if (scode[1] != OP_ANY)
+ return FALSE;
+ }
+ else if (op != OP_SOD && op != OP_ANCHOR_MATCH
+ && ((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))
+ return FALSE;
+ code += (code[1] << 8) + code[2];
+ }
+ while (*code == OP_ALT);
+ return TRUE;
+}
+
+
+
+/*************************************************
+* Check for starting with ^ or .* *
+*************************************************/
+
+/* This is called to find out if every branch starts with ^ or .* so that
+ "first char" processing can be done to speed things up in multiline
+ matching and for non-DOTALL patterns that start with .* (which must start at
+ the beginning or after \n).
+
+ Argument: points to start of expression (the bracket)
+ Returns: TRUE or FALSE
+ */
+
+static BOOL
+is_startline (code)
+ const uschar *code;
+{
+ do
+ {
+ const uschar *scode = first_significant_code (code + 3, NULL, 0, FALSE);
+ register int op = *scode;
+ if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
+ {
+ if (!is_startline (scode))
+ return FALSE;
+ }
+ else if (op == OP_TYPE_MAXSTAR || op == OP_TYPE_MINSTAR)
+ {
+ if (scode[1] != OP_ANY)
+ return FALSE;
+ }
+ else if (op != OP_CIRC)
+ return FALSE;
+ code += (code[1] << 8) + code[2];
+ }
+ while (*code == OP_ALT);
+ return TRUE;
+}
+
+
+
+/*************************************************
+* Check for ending with $ *
+*************************************************/
+
+/* This is called to find out if every branch ends with $ so that if the
+ match can only have a limited length we can start the match directly
+ at the end of the line.
+
+ Argument: points to start of expression (the bracket)
+ Returns: TRUE or FALSE
+ */
+
+static BOOL
+is_endline (code)
+ const uschar *code;
+{
+ BOOL was_dollar = FALSE, is_dollar = FALSE, found_dollar = FALSE;
+ for (;;)
+ {
+ int op;
+
+ was_dollar = is_dollar;
+ is_dollar = FALSE;
+ op = *code;
+ if (op >= OP_BRA)
+ op = OP_BRA;
+
+ switch (op)
+ {
+
+ case OP_EODN:
+ case OP_EOD:
+ found_dollar = is_dollar = TRUE;
+ /* Fall through */
+
+ case OP_END:
+ return found_dollar;
+
+ case OP_OPT:
+ code++;
+ break;
+
+ case OP_COND:
+ code += 2;
+ break;
+
+ case OP_CREF:
+ code++;
+ break;
+
+ case OP_CHARS:
+ code += code[1] + 2;
+ break;
+
+ case OP_KET_MAXSTAR:
+ case OP_KET_MINSTAR:
+ case OP_ALT:
+ case OP_KET:
+ if (!was_dollar)
+ return FALSE;
+
+ case OP_ASSERT:
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ case OP_ONCE:
+ code += 2;
+ break;
+
+ case OP_REVERSE:
+ code += 2;
+ break;
+
+ case OP_MAXSTAR:
+ case OP_MINSTAR:
+ case OP_MAXPLUS:
+ case OP_MINPLUS:
+ case OP_MAXQUERY:
+ case OP_MINQUERY:
+ case OP_TYPE_MAXSTAR:
+ case OP_TYPE_MINSTAR:
+ case OP_TYPE_MAXPLUS:
+ case OP_TYPE_MINPLUS:
+ case OP_TYPE_MAXQUERY:
+ case OP_TYPE_MINQUERY:
+ code++;
+ break;
+
+ case OP_EXACT:
+ case OP_MAXUPTO:
+ case OP_MINUPTO:
+ code += 3;
+ break;
+
+ case OP_TYPEEXACT:
+ case OP_TYPE_MAXUPTO:
+ case OP_TYPE_MINUPTO:
+ code += 3;
+ break;
+
+ case OP_NOT:
+ code++;
+ break;
+
+ case OP_NOT_MAXSTAR:
+ case OP_NOT_MINSTAR:
+ case OP_NOT_MAXPLUS:
+ case OP_NOT_MINPLUS:
+ case OP_NOT_MAXQUERY:
+ case OP_NOT_MINQUERY:
+ code++;
+ break;
+
+ case OP_NOTEXACT:
+ case OP_NOT_MAXUPTO:
+ case OP_NOT_MINUPTO:
+ code += 3;
+ break;
+
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_MAXPLUS:
+ case OP_CL_MINPLUS:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CLASS:
+ code += 32;
+ break;
+
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ code += 36;
+ break;
+
+ case OP_REF:
+ case OP_REF_MAXSTAR:
+ case OP_REF_MINSTAR:
+ case OP_REF_MAXPLUS:
+ case OP_REF_MINPLUS:
+ case OP_REF_MAXQUERY:
+ case OP_REF_MINQUERY:
+ code++;
+ break;
+
+ case OP_REF_MAXRANGE:
+ case OP_REF_MINRANGE:
+ code += 5;
+ break;
+
+ case OP_BRA:
+ code += 3;
+ break;
+
+ /* Anything else is just a one-node item */
+
+ default:
+ code++;
+ break;
+ }
+ }
+}
+
+
+
+/*************************************************
+* Check for fixed first char *
+*************************************************/
+
+/* Try to find out if there is a fixed first character. This is called for
+ unanchored expressions, as it speeds up their processing quite considerably.
+ Consider each alternative branch. If they all start with the same char, or with
+ a bracket all of whose alternatives start with the same char (recurse ad lib),
+ then we return that char, otherwise -1.
+
+ Arguments:
+ code points to start of expression (the bracket)
+ options pointer to the options (used to check casing changes)
+
+ Returns: -1 or the fixed first char
+ */
+
+static int
+find_firstchar (code, options)
+ const uschar *code;
+ int *options;
+{
+ register int c = -1;
+ do
+ {
+ int d;
+ const uschar *scode = first_significant_code (code + 3, options,
+ PCRE_CASELESS, TRUE);
+ register int op = *scode;
+
+ if (op >= OP_BRA)
+ op = OP_BRA;
+
+ switch (op)
+ {
+ default:
+ return -1;
+
+ case OP_BRA:
+ case OP_ASSERT:
+ case OP_ONCE:
+ case OP_COND:
+ if ((d = find_firstchar (scode, options)) < 0)
+ return -1;
+ if (c < 0)
+ c = d;
+ else if (c != d)
+ return -1;
+ break;
+
+ case OP_EXACT: /* Fall through */
+ scode++;
+
+ case OP_CHARS: /* Fall through */
+ scode++;
+
+ case OP_MAXPLUS:
+ case OP_MINPLUS:
+ if (c < 0)
+ c = scode[1];
+ else if (c != scode[1])
+ return -1;
+ break;
+ }
+
+ code += (code[1] << 8) + code[2];
+ }
+ while (*code == OP_ALT);
+ return c;
+}
diff --git a/pcre/regdebug.c b/pcre/regdebug.c
new file mode 100644
index 0000000..586a23b
--- /dev/null
+++ b/pcre/regdebug.c
@@ -0,0 +1,405 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+#include "internal.h"
+
+const char *pcre_OP_names[] =
+{
+ "End", "\\<", "\\>", "\\G", "\\A", "\\B", "\\b",
+ "\\Z", "\\z",
+ "Opt", "^", "$", "Any",
+ "chars", "*", "*?", " once *", "+", "+?", " once +", "?", "??", " once ?", "{", "{", " once {", "{",
+ "not", "*", "*?", " once *", "+", "+?", " once +", "?", "??", " once ?", "{", "{", " once {", "{",
+ "", "*", "*?", " once *", "+", "+?", " once +", "?", "??", " once ?", "{", "{", " once {", "{",
+ "", "*", "*?", " once *", "+", "+?", " once +", "?", "??", " once ?", "{", "{", " once {", "{",
+ "", "*", "*?", " once *", "+", "+?", " once +", "?", "??", " once ?", "{", "{", " once {",
+ "", "*", "*?", " once *", "+", "+?", " once +", "?", "??", " once ?", "{", "{", " once {",
+ "Recurse",
+ "Alt", "Ket", "Ket*", "Ket*?", "Ket once *", "Assert", "Assert not",
+ "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cref",
+ "Brazero", "Braminzero", "Branumber", "Bra"
+};
+
+static const char *TYPE_names[] =
+{
+ "invalid", "\\d", "\\s", "\\w"
+};
+
+static const char *TYPENOT_names[] =
+{
+ "Any", "\\D", "\\S", "\\W"
+};
+
+
+/*************************************************
+* Debugging function to print regexp *
+*************************************************/
+
+void
+pcre_debug (re)
+ pcre *re;
+{
+ uschar *code, *code_base;
+ int c;
+
+ printf ("Computed size = %d top_bracket = %d top_backref = %d\n",
+ re->size, re->top_bracket, re->top_backref);
+
+ if (re->max_match_size >= 0)
+ printf ("Can match up to %d characters\n",
+ re->max_match_size);
+
+
+ if (re->options != 0)
+ {
+ printf ("%s%s%s%s%s%s%s%s\n",
+ ((re->options & PCRE_ANCHORED) != 0) ? "anchored " : "",
+ ((re->options & PCRE_CASELESS) != 0) ? "caseless " : "",
+ ((re->options & PCRE_ICHANGED) != 0) ? "case state changed " : "",
+ ((re->options & PCRE_MULTILINE) != 0) ? "multiline " : "",
+ ((re->options & PCRE_DOTALL) != 0) ? "dotall " : "",
+ ((re->options & PCRE_DOLLAR_ENDONLY) != 0) ? "endonly " : "",
+ ((re->options & PCRE_EXTRA) != 0) ? "extra " : "",
+ ((re->options & PCRE_UNGREEDY) != 0) ? "ungreedy" : "");
+ }
+
+ if ((re->options & PCRE_FIRSTSET) != 0)
+ {
+ if (isascii (re->first_char) && isprint (re->first_char))
+ printf ("First char = %c\n", re->first_char);
+ else
+ printf ("First char = \\x%02x\n", re->first_char);
+ }
+
+ if ((re->options & PCRE_REQCHSET) != 0)
+ {
+ if (isascii (re->req_char) && isprint (re->req_char))
+ printf ("Req char = %c\n", re->req_char);
+ else
+ printf ("Req char = \\x%02x\n", re->req_char);
+ }
+
+ code_base = code = re->code;
+
+ for (;;)
+ {
+ int charlength;
+
+ printf ("%3d ", code - code_base);
+
+ if (*code >= OP_BRA)
+ {
+ if (*code - OP_BRA > EXTRACT_BASIC_MAX)
+ printf("%3d Bra extra", (code[1] << 8) + code[2]);
+ else
+ printf("%3d Bra %d", (code[1] << 8) + code[2], *code - OP_BRA);
+
+ code += 2;
+ }
+
+ else
+ switch (*code)
+ {
+ case OP_OPT:
+ printf (" %.2x %s", code[1], pcre_OP_names[*code]);
+ code++;
+ break;
+
+ case OP_CHARS:
+ charlength = *(++code);
+ printf ("%3d ", charlength);
+ while (charlength-- > 0)
+ {
+ c = *(++code);
+ if (isascii (c) && isprint (c))
+ printf ("%c", c);
+ else
+ printf ("\\x%02x", c);
+ }
+ break;
+
+ case OP_KET_MAXSTAR:
+ case OP_KET_MINSTAR:
+ case OP_KET_ONCESTAR:
+ case OP_ALT:
+ case OP_KET:
+ case OP_ASSERT:
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ case OP_ONCE:
+ case OP_REVERSE:
+ case OP_BRANUMBER:
+ case OP_COND:
+ case OP_CREF:
+ printf ("%3d %s", (code[1] << 8) + code[2], pcre_OP_names[*code]);
+ code += 2;
+ break;
+
+ case OP_MAXSTAR:
+ case OP_MINSTAR:
+ case OP_ONCESTAR:
+ case OP_MAXPLUS:
+ case OP_MINPLUS:
+ case OP_ONCEPLUS:
+ case OP_MAXQUERY:
+ case OP_MINQUERY:
+ case OP_ONCEQUERY:
+ c = code[1];
+ if (isascii (c) && isprint (c))
+ printf (" %c", c);
+ else
+ printf (" \\x%02x", c);
+ printf ("%s", pcre_OP_names[*code++]);
+ break;
+
+ case OP_TYPE:
+ case OP_TYPE_MAXSTAR:
+ case OP_TYPE_MINSTAR:
+ case OP_TYPE_ONCESTAR:
+ case OP_TYPE_MAXPLUS:
+ case OP_TYPE_MINPLUS:
+ case OP_TYPE_ONCEPLUS:
+ case OP_TYPE_MAXQUERY:
+ case OP_TYPE_MINQUERY:
+ case OP_TYPE_ONCEQUERY:
+ case OP_TYPENOT:
+ case OP_TYPENOT_MAXSTAR:
+ case OP_TYPENOT_MINSTAR:
+ case OP_TYPENOT_ONCESTAR:
+ case OP_TYPENOT_MAXPLUS:
+ case OP_TYPENOT_MINPLUS:
+ case OP_TYPENOT_ONCEPLUS:
+ case OP_TYPENOT_MAXQUERY:
+ case OP_TYPENOT_MINQUERY:
+ case OP_TYPENOT_ONCEQUERY:
+ c = code[1];
+ if (*code >= OP_TYPENOT)
+ printf (" %s", TYPENOT_names[c]);
+ else
+ printf (" %s", TYPE_names[c]);
+ printf ("%s", pcre_OP_names[*code]);
+ code++;
+ break;
+
+ case OP_EXACT:
+ case OP_MAXUPTO:
+ case OP_MINUPTO:
+ case OP_ONCEUPTO:
+ c = code[3];
+ if (isascii (c) && isprint (c))
+ printf (" %c%s", c, pcre_OP_names[*code]);
+ else
+ printf (" \\x%02x%s", c, pcre_OP_names[*code]);
+ if (*code != OP_EXACT)
+ printf ("0,");
+ printf ("%d}", (code[1] << 8) + code[2]);
+ if (*code == OP_MINUPTO)
+ printf ("?");
+ code += 3;
+ break;
+
+ case OP_TYPEEXACT:
+ case OP_TYPE_MAXUPTO:
+ case OP_TYPE_MINUPTO:
+ case OP_TYPE_ONCEUPTO:
+ printf (" %s%s", TYPE_names[code[3]], pcre_OP_names[*code]);
+ if (*code != OP_TYPEEXACT)
+ printf (",");
+ printf ("%d}", (code[1] << 8) + code[2]);
+ if (*code == OP_TYPE_MINUPTO)
+ printf ("?");
+ code += 3;
+ break;
+
+ case OP_TYPENOTEXACT:
+ case OP_TYPENOT_MAXUPTO:
+ case OP_TYPENOT_MINUPTO:
+ case OP_TYPENOT_ONCEUPTO:
+ printf (" %s%s", TYPENOT_names[code[3]], pcre_OP_names[*code]);
+ if (*code != OP_TYPENOTEXACT)
+ printf (",");
+ printf ("%d}", (code[1] << 8) + code[2]);
+ if (*code == OP_TYPENOT_MINUPTO)
+ printf ("?");
+ code += 3;
+ break;
+
+ case OP_NOT:
+ c = *(++code);
+
+ if (isascii (c) && isprint (c))
+ printf (" [^%c]", c);
+ else
+ printf (" [^\\x%02x]", c);
+ break;
+
+ case OP_NOT_MAXSTAR:
+ case OP_NOT_MINSTAR:
+ case OP_NOT_ONCESTAR:
+ case OP_NOT_MAXPLUS:
+ case OP_NOT_MINPLUS:
+ case OP_NOT_ONCEPLUS:
+ case OP_NOT_MAXQUERY:
+ case OP_NOT_MINQUERY:
+ case OP_NOT_ONCEQUERY:
+ c = code[1];
+ if (isascii (c) && isprint (c))
+ printf (" [^%c]", c);
+ else
+ printf (" [^\\x%02x]", c);
+ printf ("%s", pcre_OP_names[*code++]);
+ break;
+
+ case OP_NOTEXACT:
+ case OP_NOT_MAXUPTO:
+ case OP_NOT_MINUPTO:
+ case OP_NOT_ONCEUPTO:
+ c = code[3];
+ if (isascii (c) && isprint (c))
+ printf (" [^%c]%s", c, pcre_OP_names[*code]);
+ else
+ printf (" [^\\x%02x]%s", c, pcre_OP_names[*code]);
+ if (*code != OP_NOTEXACT)
+ printf (",");
+ printf ("%d}", (code[1] << 8) + code[2]);
+ if (*code == OP_NOT_MINUPTO)
+ printf ("?");
+ code += 3;
+ break;
+
+ case OP_REF:
+ case OP_REF_MAXSTAR:
+ case OP_REF_MINSTAR:
+ case OP_REF_ONCESTAR:
+ case OP_REF_MAXPLUS:
+ case OP_REF_MINPLUS:
+ case OP_REF_ONCEPLUS:
+ case OP_REF_MAXQUERY:
+ case OP_REF_MINQUERY:
+ case OP_REF_ONCEQUERY:
+ case OP_REF_MAXRANGE:
+ case OP_REF_MINRANGE:
+ case OP_REF_ONCERANGE:
+ c = *code - OP_REF + OP_CLASS;
+ printf (" \\%d", code[1] * 256 + code[2]);
+ code += 2;
+ goto CLASS_REF_REPEAT;
+
+ case OP_CLASS:
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_ONCESTAR:
+ case OP_CL_MAXPLUS:
+ case OP_CL_MINPLUS:
+ case OP_CL_ONCEPLUS:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CL_ONCEQUERY:
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ case OP_CL_ONCERANGE:
+ {
+ int i, min, max;
+ c = *code++;
+ printf (" [");
+
+ for (i = 0; i < 256; i++)
+ {
+ if ((code[i / 8] & (1 << (i & 7))) != 0)
+ {
+ int j;
+ for (j = i + 1; j < 256; j++)
+ if ((code[j / 8] & (1 << (j & 7))) == 0)
+ break;
+ if (i == '-' || i == ']')
+ printf ("\\");
+ if (isascii (i) && isprint (i))
+ printf ("%c", i);
+ else
+ printf ("\\x%02x", i);
+ if (--j > i)
+ {
+ printf ("-");
+ if (j == '-' || j == ']')
+ printf ("\\");
+ if (isascii (j) && isprint (j))
+ printf ("%c", j);
+ else
+ printf ("\\x%02x", j);
+ }
+ i = j;
+ }
+ }
+ printf ("]");
+ code += 31;
+
+ CLASS_REF_REPEAT:
+
+ printf ("%s", pcre_OP_names[c]);
+
+ if (c == OP_CL_MAXRANGE || c == OP_CL_MINRANGE || c == OP_CL_ONCERANGE ||
+ c == OP_REF_MAXRANGE || c == OP_REF_MINRANGE || c == OP_REF_ONCERANGE)
+ {
+ min = (code[1] << 8) + code[2];
+ max = (code[3] << 8) + code[4];
+ if (max == 0)
+ printf ("%d,}", min);
+ else
+ printf ("%d,%d}", min, max);
+ if (c == OP_CL_MINRANGE || c == OP_REF_MINRANGE)
+ printf ("?");
+ code += 4;
+ break;
+ }
+ }
+ break;
+
+ case OP_END:
+ printf (" %s\n", pcre_OP_names[*code]);
+ printf ("------------------------------------------------------------------\n");
+ return;
+
+ /* Anything else is just a one-node item */
+
+ default:
+ printf (" %s", pcre_OP_names[*code]);
+ break;
+ }
+
+ code++;
+ printf ("\n");
+ }
+}
+
diff --git a/pcre/regexec.c b/pcre/regexec.c
new file mode 100644
index 0000000..f170016
--- /dev/null
+++ b/pcre/regexec.c
@@ -0,0 +1,2095 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+/* Include the internals header, which itself includes Standard C headers plus
+ the external pcre header. */
+
+#include "internal.h"
+
+/* Use a macro for debugging printing, 'cause that limits the use of #ifdef
+ inline, and there are *still* stupid compilers about that don't like indented
+ pre-processor statements. I suppose it's only been 10 years... */
+
+#ifdef DEBUG
+#define DPRINTF(p) printf p
+#else
+#define DPRINTF(p) /*nothing */
+#endif
+
+/* Allow compilation as C++ source code, should anybody want to do that. */
+
+#ifdef __cplusplus
+#define class pcre_class
+#endif
+
+
+/* Structure for building a chain of data that actually lives on the
+ stack, for holding the values of the subject pointer at the start of each
+ subpattern, so as to detect when an empty string has been matched by a
+ subpattern - to break infinite loops. */
+
+typedef struct eptrblock
+ {
+ struct eptrblock *prev;
+ const uschar *saved_eptr;
+ int flags;
+ }
+eptrblock;
+
+/* Flag bits for the match() function */
+
+#define match_condassert 0x01 /* Called to check a condition assertion */
+#define match_isgroup 0x02 /* Set if start of bracketed group */
+#define match_isbrazero 0x04 /* Set if matching optional bracketed group */
+
+
+/*************************************************
+* Macros and tables for character handling *
+*************************************************/
+
+#define GETCHARINC(c, eptr) c = *eptr++;
+#define GETCHAR(c, eptr) c = *eptr;
+
+#ifdef DEBUG
+/*************************************************
+* Debugging function to print chars *
+*************************************************/
+
+/* Print a sequence of chars in printable format, stopping at the end of the
+ subject if the requested.
+
+ Arguments:
+ p points to characters
+ length number to print
+ is_subject TRUE if printing from within md->start_subject
+ md pointer to matching data block, if is_subject is TRUE
+
+ Returns: nothing
+ */
+
+static void
+pchars (p, length, is_subject, md)
+ const uschar *p;
+ int length;
+ BOOL is_subject;
+ match_data *md;
+{
+ int c;
+ if (is_subject && length > md->end_subject - p)
+ length = md->end_subject - p;
+ while (length-- > 0)
+ if (isprint (c = *(p++)))
+ printf ("%c", c);
+ else
+ printf ("\\x%02x", c);
+}
+#endif
+
+/*************************************************
+* Match a back-reference *
+*************************************************/
+
+/* If a back reference hasn't been set, the length that is passed is greater
+ than the number of characters left in the string, so the match fails.
+
+ Arguments:
+ offset index into the offset vector
+ eptr points into the subject
+ length length to be matched
+ md points to match data block
+ ims the ims flags
+
+ Returns: TRUE if matched
+ */
+
+static BOOL
+match_ref (offset, eptr, length, md, ims)
+ int offset;
+ register const uschar *eptr;
+ int length;
+ match_data *md;
+ unsigned long int ims;
+{
+ const uschar *p = md->start_subject + md->offset_vector[offset];
+
+#ifdef DEBUG
+ if (eptr >= md->end_subject)
+ printf ("matching subject ");
+ else
+ {
+ printf ("matching subject ");
+ pchars (eptr, length, TRUE, md);
+ }
+ printf (" against backref ");
+ pchars (p, length, FALSE, md);
+ printf ("\n");
+#endif
+
+ /* Always fail if not enough characters left */
+ if (length > md->end_subject - eptr)
+ return FALSE;
+
+ /* Separate the caselesss case for speed */
+ if ((ims & PCRE_CASELESS) != 0)
+ {
+ while (length-- > 0)
+ if (md->lcc[*p++] != md->lcc[*eptr++])
+ return FALSE;
+ }
+ else
+ {
+ while (length-- > 0)
+ if (*p++ != *eptr++)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+
+/*************************************************
+* Match from current position *
+*************************************************/
+
+/* On entry ecode points to the first opcode, and eptr to the first character
+ in the subject string, while eptrb holds the value of eptr at the start of the
+ last bracketed group - used for breaking infinite loops matching zero-length
+ strings.
+
+ Arguments:
+ eptr pointer in subject
+ ecode position in code
+ offset_top current top pointer
+ md pointer to "static" info for the match
+ ims current /i, /m, and /s options
+ eptrb pointer to chain of blocks containing eptr at start of
+ brackets - for testing for empty matches
+ flags can contain
+ match_condassert - this is an assertion condition
+ match_isgroup - this is the start of a bracketed group
+ match_isbrazero - this is after a BRAZERO
+
+ Returns: TRUE if matched
+ */
+
+static BOOL
+match (eptr, ecode, offset_top, md, ims, eptrb, flags)
+ register const uschar *eptr;
+ register const uschar *ecode;
+ int offset_top;
+ match_data *md;
+ unsigned long int ims;
+ eptrblock *eptrb;
+ int flags;
+{
+ unsigned long int original_ims = ims; /* Save for resetting on ')' */
+ const uschar *data;
+ eptrblock newptrb;
+
+ /* At the start of a bracketed group, add the current subject pointer to the
+ stack of such pointers, to be re-instated at the end of the group when we hit
+ the closing ket. When match() is called in other circumstances, we don't add to
+ the stack. */
+ if ((flags & match_isgroup) != 0)
+ {
+ newptrb.prev = eptrb;
+ newptrb.saved_eptr = eptr;
+ newptrb.flags = flags;
+ eptrb = &newptrb;
+ }
+
+ /* Now start processing the operations. */
+ for (;;)
+ {
+ int op = (int) *ecode;
+ int min, max, ctype;
+ register int i;
+ register int c;
+ int kind = 0;
+
+ /* Opening capturing bracket. If there is space in the offset vector, save
+ the current subject position in the working slot at the top of the vector. We
+ mustn't change the current values of the data slot, because they may be set
+ from a previous iteration of this group, and be referred to by a reference
+ inside the group.
+
+ If the bracket fails to match, we need to restore this value and also the
+ values of the final offsets, in case they were set by a previous iteration of
+ the same bracket.
+
+ If there isn't enough space in the offset vector, treat this as if it were a
+ non-capturing bracket. Don't worry about setting the flag for the error case
+ here; that is handled in the code for KET. */
+
+ if (op > OP_BRA)
+ {
+ int offset;
+ int number = op - OP_BRA;
+
+ /* For extended extraction brackets (large number), we have to fish out the
+ number from a dummy opcode at the start. */
+
+ if (number > EXTRACT_BASIC_MAX)
+ number = (ecode[4] << 8) | ecode[5];
+
+ offset = number << 1;
+
+#ifdef DEBUG
+ printf ("start bracket %d subject=", number);
+ pchars (eptr, 16, TRUE, md);
+ printf ("\n");
+#endif
+
+ if (offset < md->offset_max)
+ {
+ int save_offset1 = md->offset_vector[offset];
+ int save_offset2 = md->offset_vector[offset + 1];
+ int save_offset3 = md->offset_vector[md->offset_end - number];
+
+ DPRINTF (("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
+ md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
+
+ do
+ {
+ if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup))
+ return TRUE;
+ ecode += (ecode[1] << 8) + ecode[2];
+ }
+ while (*ecode == OP_ALT);
+
+ DPRINTF (("bracket %d failed\n", number));
+
+ md->offset_vector[offset] = save_offset1;
+ md->offset_vector[offset + 1] = save_offset2;
+ md->offset_vector[md->offset_end - number] = save_offset3;
+
+ return FALSE;
+ }
+
+ /* Insufficient room for saving captured contents */
+
+ else
+ op = OP_BRA;
+ }
+
+ /* Other types of node can be handled by a switch */
+
+ switch (op)
+ {
+ case OP_BRA: /* Non-capturing bracket: optimized */
+ DPRINTF (("start bracket 0\n"));
+ do
+ {
+ if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup))
+ return TRUE;
+ ecode += (ecode[1] << 8) + ecode[2];
+ }
+ while (*ecode == OP_ALT);
+ DPRINTF (("bracket 0 failed\n"));
+ return FALSE;
+
+ /* Conditional group: compilation checked that there are no more than
+ two branches. If the condition is false, skipping the first branch takes us
+ past the end if there is only one branch, but that's OK because that is
+ exactly what going to the ket would do. */
+
+ case OP_COND:
+ if (ecode[3] == OP_CREF) /* Condition is extraction test */
+ {
+ int offset = (ecode[4] << 9) | (ecode[5] << 1); /* Doubled reference number */
+ return match (eptr,
+ ecode + ((offset < offset_top && md->offset_vector[offset] >= 0) ?
+ 6 : 3 + (ecode[1] << 8) + ecode[2]),
+ offset_top, md, ims, eptrb, match_isgroup);
+ }
+
+ /* The condition is an assertion. Call match() to evaluate it - setting
+ the final argument TRUE causes it to stop at the end of an assertion. */
+
+ else
+ {
+ if (match (eptr, ecode + 3, offset_top, md, ims, NULL,
+ match_condassert | match_isgroup))
+ {
+ ecode += 3 + (ecode[4] << 8) + ecode[5];
+ while (*ecode == OP_ALT)
+ ecode += (ecode[1] << 8) + ecode[2];
+ }
+ else
+ ecode += (ecode[1] << 8) + ecode[2];
+ return match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup);
+ }
+ /* Control never reaches here */
+
+ /* Skip over conditional reference data or large extraction number data if
+ encountered */
+
+ case OP_CREF:
+ case OP_BRANUMBER:
+ ecode += 3;
+ continue;
+
+ /* End of the pattern. If PCRE_NOTEMPTY is set, fail if we have matched
+ an empty string - recursion will then try other alternatives, if any. */
+
+ case OP_END:
+ if (md->notempty && eptr == md->start_match)
+ return FALSE;
+ md->end_match_ptr = eptr; /* Record where we ended */
+ md->end_offset_top = offset_top; /* and how many extracts were taken */
+ return TRUE;
+
+ /* Change option settings */
+
+ case OP_OPT:
+ ims = ecode[1];
+ ecode += 2;
+ DPRINTF (("ims set to %02lx\n", ims));
+ continue;
+
+ /* Assertion brackets. Check the alternative branches in turn - the
+ matching won't pass the KET for an assertion. If any one branch matches,
+ the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
+ start of each branch to move the current point backwards, so the code at
+ this level is identical to the lookahead case. */
+
+ case OP_ASSERT:
+ case OP_ASSERTBACK:
+ do
+ {
+ if (match (eptr, ecode + 3, offset_top, md, ims, NULL, match_isgroup))
+ break;
+ ecode += (ecode[1] << 8) + ecode[2];
+ }
+ while (*ecode == OP_ALT);
+ if (*ecode == OP_KET)
+ return FALSE;
+
+ /* If checking an assertion for a condition, return TRUE. */
+
+ if ((flags & match_condassert) != 0)
+ return TRUE;
+
+ /* Continue from after the assertion, updating the offsets high water
+ mark, since extracts may have been taken during the assertion. */
+
+ do
+ ecode += (ecode[1] << 8) + ecode[2];
+ while (*ecode == OP_ALT);
+ ecode += 3;
+ offset_top = md->end_offset_top;
+ continue;
+
+ /* Negative assertion: all branches must fail to match */
+
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK_NOT:
+ do
+ {
+ if (match (eptr, ecode + 3, offset_top, md, ims, NULL, match_isgroup))
+ return FALSE;
+ ecode += (ecode[1] << 8) + ecode[2];
+ }
+ while (*ecode == OP_ALT);
+
+ if ((flags & match_condassert) != 0)
+ return TRUE;
+
+ ecode += 3;
+ continue;
+
+ /* Move the subject pointer back. This occurs only at the start of
+ each branch of a lookbehind assertion. If we are too close to the start to
+ move back, this match function fails. */
+
+ case OP_REVERSE:
+ eptr -= (ecode[1] << 8) + ecode[2];
+
+ if (eptr < md->start_subject)
+ return FALSE;
+ ecode += 3;
+ continue;
+
+ /* Recursion matches the current regex, nested. If there are any capturing
+ brackets started but not finished, we have to save their starting points
+ and reinstate them after the recursion. However, we don't know how many
+ such there are (offset_top records the completed total) so we just have
+ to save all the potential data. There may be up to 99 such values, which
+ is a bit large to put on the stack, but using malloc for small numbers
+ seems expensive. As a compromise, the stack is used when there are fewer
+ than 16 values to store; otherwise malloc is used. A problem is what to do
+ if the malloc fails ... there is no way of returning to the top level with
+ an error. Save the top 15 values on the stack, and accept that the rest
+ may be wrong. */
+
+ case OP_RECURSE:
+ {
+ BOOL rc;
+ int *save;
+ int stacksave[15];
+
+ c = md->offset_max;
+
+ if (c < 16)
+ save = stacksave;
+ else
+ {
+ save = (int *) (pcre_malloc) ((c + 1) * sizeof (int));
+ if (save == NULL)
+ {
+ save = stacksave;
+ c = 15;
+ }
+ }
+
+ for (i = 1; i <= c; i++)
+ save[i] = md->offset_vector[md->offset_end - i];
+ rc = match (eptr, md->start_pattern, offset_top, md, ims, eptrb,
+ match_isgroup);
+ for (i = 1; i <= c; i++)
+ md->offset_vector[md->offset_end - i] = save[i];
+ if (save != stacksave)
+ (pcre_free) (save);
+ if (!rc)
+ return FALSE;
+
+ /* In case the recursion has set more capturing values, save the final
+ number, then move along the subject till after the recursive match,
+ and advance one byte in the pattern code. */
+
+ offset_top = md->end_offset_top;
+ eptr = md->end_match_ptr;
+ ecode++;
+ }
+ continue;
+
+ /* "Once" brackets are like assertion brackets except that after a match,
+ the point in the subject string is not moved back. Thus there can never be
+ a move back into the brackets. Check the alternative branches in turn - the
+ matching won't pass the KET for this kind of subpattern. If any one branch
+ matches, we carry on as at the end of a normal bracket, leaving the subject
+ pointer. */
+
+ case OP_ONCE:
+ {
+ const uschar *prev = ecode;
+ const uschar *saved_eptr = eptr;
+
+ do
+ {
+ if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup))
+ break;
+ ecode += (ecode[1] << 8) + ecode[2];
+ }
+ while (*ecode == OP_ALT);
+
+ /* If hit the end of the group (which could be repeated), fail */
+
+ if (*ecode != OP_ONCE && *ecode != OP_ALT)
+ return FALSE;
+
+ /* Continue as from after the assertion, updating the offsets high water
+ mark, since extracts may have been taken. */
+
+ do
+ ecode += (ecode[1] << 8) + ecode[2];
+ while (*ecode == OP_ALT);
+
+ offset_top = md->end_offset_top;
+ eptr = md->end_match_ptr;
+
+ /* For a non-repeating ket, just continue at this level. This also
+ happens for a repeating ket if no characters were matched in the group.
+ This is the forcible breaking of infinite loops as implemented in Perl
+ 5.005. If there is an options reset, it will get obeyed in the normal
+ course of events. */
+
+ if (*ecode == OP_KET || eptr == saved_eptr)
+ {
+ ecode += 3;
+ continue;
+ }
+
+ /* The repeating kets try the rest of the pattern or restart from the
+ preceding bracket, in the appropriate order. We need to reset any options
+ that changed within the bracket before re-running it, so check the next
+ opcode. */
+
+ if (ecode[3] == OP_OPT)
+ {
+ ims = (ims & ~PCRE_IMS) | ecode[4];
+ DPRINTF (("ims set to %02lx at group repeat\n", ims));
+ }
+
+ if (*ecode == OP_KET_MINSTAR)
+ {
+ if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0) ||
+ match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
+ return TRUE;
+ }
+ else
+ /* OP_KET_MAXSTAR or OP_KET_ONCESTAR (FIXME!) */
+ {
+ if (match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
+ match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ }
+ }
+ return FALSE;
+
+ /* An alternation is the end of a branch; scan along to find the end of the
+ bracketed group and go to there. */
+
+ case OP_ALT:
+ do
+ ecode += (ecode[1] << 8) + ecode[2];
+ while (*ecode == OP_ALT);
+ continue;
+
+ /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating
+ that it may occur zero times. It may repeat infinitely, or not at all -
+ i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper
+ repeat limits are compiled as a number of copies, with the optional ones
+ preceded by BRAZERO or BRAMINZERO. */
+
+ case OP_BRAZERO:
+ {
+ const uschar *next = ecode + 1;
+ if (match (eptr, next, offset_top, md, ims, eptrb,
+ match_isgroup | match_isbrazero))
+ return TRUE;
+ do
+ next += (next[1] << 8) + next[2];
+ while (*next == OP_ALT);
+ ecode = next + 3;
+ }
+ continue;
+
+ case OP_BRAMINZERO:
+ {
+ const uschar *next = ecode + 1;
+ do
+ next += (next[1] << 8) + next[2];
+ while (*next == OP_ALT);
+ if (match (eptr, next + 3, offset_top, md, ims, eptrb, match_isgroup))
+ return TRUE;
+ ecode++;
+ }
+ continue;
+
+ /* End of a group, repeated or non-repeating. If we are at the end of
+ an assertion "group", stop matching and return TRUE, but record the
+ current high water mark for use by positive assertions. Do this also
+ for the "once" (not-backup up) groups. */
+
+ case OP_KET:
+ case OP_KET_MINSTAR:
+ case OP_KET_MAXSTAR:
+ case OP_KET_ONCESTAR:
+ {
+ const uschar *prev = ecode - (ecode[1] << 8) - ecode[2];
+ const uschar *saved_eptr = eptrb->saved_eptr;
+
+ eptrb = eptrb->prev; /* Back up the stack of bracket start pointers */
+
+ if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
+ *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
+ *prev == OP_ONCE)
+ {
+ md->end_match_ptr = eptr; /* For ONCE */
+ md->end_offset_top = offset_top;
+ return TRUE;
+ }
+
+ /* In all other cases except a conditional group we have to check the
+ group number back at the start and if necessary complete handling an
+ extraction by setting the offsets and bumping the high water mark. */
+
+ if (*prev != OP_COND)
+ {
+ int offset;
+ int number = *prev - OP_BRA;
+
+ /* For extended extraction brackets (large number), we have to fish out
+ the number from a dummy opcode at the start. */
+
+ if (number > EXTRACT_BASIC_MAX)
+ number = (prev[4] << 8) | prev[5];
+
+ offset = number << 1;
+#ifdef DEBUG
+ printf ("end bracket %d\n", number);
+#endif
+
+ /* Void matches (eptr == saved_eptr) are reported if they are the
+ first ones (md->offset_vector[offset] is still -1) or if the
+ match is not optional (the match_isbrazero flag is not active). */
+ if (number > 0
+ && (eptr > saved_eptr
+ || offset_top <= offset
+ || md->offset_vector[offset] == -1
+ || !(eptrb->flags & match_isbrazero)))
+ {
+ if (offset >= md->offset_max)
+ md->offset_overflow = TRUE;
+ {
+ if (offset_top <= offset)
+ offset_top = offset + 2;
+ md->offset_vector[offset] =
+ md->offset_vector[md->offset_end - number];
+ md->offset_vector[offset + 1] = eptr - md->start_subject;
+ }
+ }
+ }
+
+ /* Reset the value of the ims flags, in case they got changed during
+ the group. */
+
+ ims = original_ims;
+ DPRINTF (("ims reset to %02lx\n", ims));
+
+ /* For a non-repeating ket, just continue at this level. This also
+ happens for a repeating ket if no characters were matched in the group.
+ This is the forcible breaking of infinite loops as implemented in Perl
+ 5.005. If there is an options reset, it will get obeyed in the normal
+ course of events. */
+
+ if (*ecode == OP_KET || eptr == saved_eptr)
+ {
+ ecode += 3;
+ continue;
+ }
+
+ /* The repeating kets try the rest of the pattern or restart from the
+ preceding bracket, in the appropriate order. */
+
+ if (*ecode == OP_KET_MINSTAR)
+ {
+ if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0) ||
+ match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
+ return TRUE;
+ }
+ else
+ /* OP_KET_MAXSTAR or OP_KET_ONCESTAR (FIXME!) */
+ {
+ if (match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
+ match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ }
+ }
+ return FALSE;
+
+ /* Start of subject unless notbol, or after internal newline if multiline */
+
+ case OP_CIRC:
+ if (md->notbol && eptr == md->start_subject)
+ return FALSE;
+ if ((ims & PCRE_MULTILINE) != 0)
+ {
+ if (eptr != md->start_subject && eptr[-1] != '\n')
+ return FALSE;
+ ecode++;
+ continue;
+ }
+ /* ... else fall through */
+
+ /* Start of subject assertion */
+
+ case OP_SOD:
+ if (eptr != md->start_subject)
+ return FALSE;
+ ecode++;
+ continue;
+
+ /* No implicit advancing assertion */
+
+ case OP_ANCHOR_MATCH:
+ if (eptr != md->first_start)
+ return FALSE;
+ ecode++;
+ continue;
+
+ /* Assert before internal newline if multiline, or before a terminating
+ newline unless endonly is set, else end of subject unless noteol is set. */
+
+ case OP_DOLL:
+ if ((ims & PCRE_MULTILINE) != 0)
+ {
+ if (eptr < md->end_subject)
+ {
+ if (*eptr != '\n')
+ return FALSE;
+ }
+ else
+ {
+ if (md->noteol)
+ return FALSE;
+ }
+ ecode++;
+ continue;
+ }
+ else
+ {
+ if (md->noteol)
+ return FALSE;
+ if (!md->endonly)
+ {
+ if (eptr < md->end_subject - 1 ||
+ (eptr == md->end_subject - 1 && *eptr != '\n'))
+ return FALSE;
+
+ ecode++;
+ continue;
+ }
+ }
+ /* ... else fall through */
+
+ /* End of subject assertion (\z) */
+
+ case OP_EOD:
+ if (eptr < md->end_subject)
+ return FALSE;
+ ecode++;
+ continue;
+
+ /* End of subject or ending \n assertion (\Z) */
+
+ case OP_EODN:
+ if (eptr < md->end_subject - 1 ||
+ (eptr == md->end_subject - 1 && *eptr != '\n'))
+ return FALSE;
+ ecode++;
+ continue;
+
+ /* Word boundary assertions */
+
+ case OP_NOT_WORD_BOUNDARY:
+ case OP_WORD_BOUNDARY:
+ {
+ BOOL prev_is_word = (eptr != md->start_subject) &&
+ ((md->ctypes[eptr[-1]] & ctype_word) != 0);
+ BOOL cur_is_word = (eptr < md->end_subject) &&
+ ((md->ctypes[*eptr] & ctype_word) != 0);
+ if ((*ecode++ == OP_WORD_BOUNDARY) ?
+ cur_is_word == prev_is_word : cur_is_word != prev_is_word)
+ return FALSE;
+ }
+ continue;
+
+ case OP_BEG_WORD:
+ case OP_END_WORD:
+ {
+ BOOL prev_is_word = (eptr != md->start_subject) &&
+ ((md->ctypes[eptr[-1]] & ctype_word) != 0);
+ BOOL cur_is_word = (eptr < md->end_subject) &&
+ ((md->ctypes[*eptr] & ctype_word) != 0);
+ if (cur_is_word == prev_is_word ||
+ ((*ecode++ == OP_BEG_WORD) ? prev_is_word : cur_is_word))
+ return FALSE;
+ }
+ continue;
+
+ /* Match a single character type; inline for speed */
+
+ case OP_ANY:
+ if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject && *eptr == '\n')
+ return FALSE;
+ if (eptr++ >= md->end_subject)
+ return FALSE;
+ ecode++;
+ continue;
+
+ case OP_TYPE:
+ ctype = 1 << ecode[1]; /* Code for the character type */
+
+ if (eptr >= md->end_subject || (md->ctypes[*eptr++] & ctype) == 0)
+ return FALSE;
+ ecode += 2;
+ continue;
+
+ case OP_TYPENOT:
+ ctype = ecode[1]; /* Code for the character type */
+ if (ctype != 0 || !(ims & PCRE_DOTALL))
+ ctype = 1 << ctype;
+
+ if (eptr >= md->end_subject || !(md->ctypes[*eptr++] & ctype) == 0)
+ return FALSE;
+ ecode += 2;
+ continue;
+
+ /* Match a back reference, possibly repeatedly. Look past the end of the
+ item to see if there is repeat information following. The code is similar
+ to that for character classes, but repeated for efficiency. Then obey
+ similar code to character type repeats - written out again for speed.
+ However, if the referenced string is the empty string, always treat
+ it as matched, any number of times (otherwise there could be infinite
+ loops). */
+
+ case OP_REF:
+ {
+ int length;
+ int offset = (ecode[1] << 9) | (ecode[2] << 1); /* Doubled reference number */
+ ecode += 3; /* Advance past the item */
+
+ /* If the reference is unset, set the length to be longer than the amount
+ of subject left; this ensures that every attempt at a match fails. We
+ can't just fail here, because of the possibility of quantifiers with zero
+ minima. */
+
+ length = (offset >= offset_top || md->offset_vector[offset] < 0) ?
+ md->end_subject - eptr + 1 :
+ md->offset_vector[offset + 1] - md->offset_vector[offset];
+
+ if (!match_ref (offset, eptr, length, md, ims))
+ return FALSE;
+ eptr += length;
+ continue; /* With the main loop */
+ }
+
+ case OP_REF_MAXSTAR:
+ case OP_REF_MINSTAR:
+ case OP_REF_ONCESTAR:
+ data = ecode;
+ kind = *ecode++ - OP_REF_MAXSTAR;
+ min = 0, max = INT_MAX;
+ goto REPEATREF;
+
+ case OP_REF_MAXPLUS:
+ case OP_REF_MINPLUS:
+ case OP_REF_ONCEPLUS:
+ data = ecode;
+ kind = *ecode++ - OP_REF_MAXPLUS;
+ min = 1, max = INT_MAX;
+ goto REPEATREF;
+
+ case OP_REF_MAXQUERY:
+ case OP_REF_MINQUERY:
+ case OP_REF_ONCEQUERY:
+ data = ecode;
+ kind = *ecode++ - OP_REF_MAXQUERY;
+ min = 0, max = 1;
+ goto REPEATREF;
+
+ case OP_REF_MAXRANGE:
+ case OP_REF_MINRANGE:
+ case OP_REF_ONCERANGE:
+ data = ecode;
+ kind = *ecode++ - OP_REF_MINRANGE;
+ min = (ecode[2] << 8) + ecode[3];
+ max = (ecode[4] << 8) + ecode[5];
+ ecode += 4;
+
+ REPEATREF:
+ {
+ int length;
+ int offset = (data[1] << 9) | (data[2] << 1); /* Doubled reference number */
+ ecode += 2; /* Advance past the item */
+ if (max == 0)
+ max = INT_MAX;
+
+ /* If the reference is unset, set the length to be longer than the amount
+ of subject left; this ensures that every attempt at a match fails. We
+ can't just fail here, because of the possibility of quantifiers with zero
+ minima. */
+
+ length = (offset >= offset_top || md->offset_vector[offset] < 0) ?
+ md->end_subject - eptr + 1 :
+ md->offset_vector[offset + 1] - md->offset_vector[offset];
+
+ /* If the length of the reference is zero, just continue with the
+ main loop. */
+
+ if (length == 0)
+ continue;
+
+ /* First, ensure the minimum number of matches are present. We get back
+ the length of the reference string explicitly rather than passing the
+ address of eptr, so that eptr can be a register variable. */
+
+ for (i = 1; i <= min; i++)
+ {
+ if (!match_ref (offset, eptr, length, md, ims))
+ return FALSE;
+ eptr += length;
+ }
+
+ /* If min = max, continue at the same level without recursion.
+ They are not both allowed to be zero. */
+
+ if (min == max)
+ continue;
+
+ /* If minimizing, keep trying and advancing the pointer */
+
+ if (kind == KIND_MIN)
+ {
+ for (i = min;; i++)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ if (i >= max || !match_ref (offset, eptr, length, md, ims))
+ return FALSE;
+ eptr += length;
+ }
+ /* Control never gets here */
+ }
+
+ /* If maximizing, find the longest string and work backwards */
+
+ else
+ {
+ const uschar *pp = eptr;
+ for (i = min; i < max; i++)
+ {
+ if (!match_ref (offset, eptr, length, md, ims))
+ break;
+ eptr += length;
+ }
+ if (kind == KIND_MAX)
+ {
+ while (eptr >= pp)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ eptr -= length;
+ }
+ return FALSE;
+ }
+ }
+ }
+ continue;
+
+
+ /* Match a character class, possibly repeatedly. Look past the end of the
+ item to see if there is repeat information following. Then obey similar
+ code to character type repeats - written out again for speed. */
+
+ case OP_CLASS:
+ {
+ data = ecode + 1; /* Save for matching */
+ ecode += 33; /* Advance past the item */
+
+ if (eptr >= md->end_subject)
+ return FALSE;
+
+ GETCHARINC (c, eptr) /* Get character; increment eptr */
+ if ((data[c / 8] & (1 << (c & 7))) == 0)
+ return FALSE;
+ }
+ continue;
+
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_ONCESTAR:
+ kind = *ecode++ - OP_CL_MAXSTAR;
+ data = ecode;
+ min = 0, max = INT_MAX;
+ goto REPEATCLASS;
+
+ case OP_CL_MAXPLUS:
+ case OP_CL_MINPLUS:
+ case OP_CL_ONCEPLUS:
+ kind = *ecode++ - OP_CL_MAXPLUS;
+ data = ecode;
+ min = 1, max = INT_MAX;
+ goto REPEATCLASS;
+
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CL_ONCEQUERY:
+ kind = *ecode++ - OP_CL_MAXQUERY;
+ data = ecode;
+ min = 0, max = 1;
+ goto REPEATCLASS;
+
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ case OP_CL_ONCERANGE:
+ kind = *ecode++ - OP_CL_MAXRANGE;
+ data = ecode;
+ min = (ecode[32] << 8) + ecode[33];
+ max = (ecode[34] << 8) + ecode[35];
+ ecode += 4;
+
+ REPEATCLASS:
+ ecode += 32; /* Advance past the item */
+ if (max == 0)
+ max = INT_MAX;
+
+ /* First, ensure the minimum number of matches are present. */
+
+ for (i = 1; i <= min; i++)
+ {
+ if (eptr >= md->end_subject)
+ return FALSE;
+ GETCHARINC (c, eptr) /* Get character; increment eptr */
+
+ if ((data[c / 8] & (1 << (c & 7))) != 0)
+ continue;
+ return FALSE;
+ }
+
+ /* If max == min we can continue with the main loop without the
+ need to recurse. */
+
+ if (min == max)
+ continue;
+
+ /* If minimizing, keep testing the rest of the expression and advancing
+ the pointer while it matches the class. */
+
+ if (kind == KIND_MIN)
+ {
+ for (i = min;; i++)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ if (i >= max || eptr >= md->end_subject)
+ return FALSE;
+ GETCHARINC (c, eptr) /* Get character; increment eptr */
+
+ if ((data[c / 8] & (1 << (c & 7))) != 0)
+ continue;
+ return FALSE;
+ }
+ /* Control never gets here */
+ }
+
+ /* If maximizing, find the longest possible run, then work backwards. */
+
+ else
+ {
+ const uschar *pp = eptr;
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject)
+ break;
+ GETCHAR (c, eptr) /* Get character */
+
+ if ((data[c / 8] & (1 << (c & 7))) == 0)
+ break;
+ eptr++;
+ }
+
+ if (kind == KIND_MAX)
+ {
+ while (eptr >= pp)
+ {
+ if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+ }
+
+ continue;
+
+ /* Match a run of characters */
+
+ case OP_CHARS:
+ {
+ register int length = ecode[1];
+ ecode += 2;
+
+#ifdef DEBUG /* Sigh. Some compilers never learn. */
+ if (eptr >= md->end_subject)
+ printf ("matching subject against pattern ");
+ else
+ {
+ printf ("matching subject ");
+ pchars (eptr, length, TRUE, md);
+ printf (" against pattern ");
+ }
+ pchars (ecode, length, FALSE, md);
+ printf ("\n");
+#endif
+
+ if (length > md->end_subject - eptr)
+ return FALSE;
+ if ((ims & PCRE_CASELESS) != 0)
+ {
+ while (length-- > 0)
+ if (md->lcc[*ecode++] != md->lcc[*eptr++])
+ return FALSE;
+ }
+ else
+ {
+ while (length-- > 0)
+ if (*ecode++ != *eptr++)
+ return FALSE;
+ }
+ }
+ continue;
+
+ /* Match a single character repeatedly; different opcodes share code. */
+
+ case OP_EXACT:
+ min = max = (ecode[1] << 8) + ecode[2];
+ ecode += 3;
+ goto REPEATCHAR;
+
+ case OP_MAXUPTO:
+ case OP_MINUPTO:
+ case OP_ONCEUPTO:
+ min = 0;
+ max = (ecode[1] << 8) + ecode[2];
+ kind = *ecode - OP_MAXUPTO;
+ ecode += 3;
+ goto REPEATCHAR;
+
+ case OP_MAXSTAR:
+ case OP_MINSTAR:
+ case OP_ONCESTAR:
+ kind = *ecode++ - OP_MAXSTAR;
+ min = 0, max = INT_MAX;
+ goto REPEATCHAR;
+
+ case OP_MAXPLUS:
+ case OP_MINPLUS:
+ case OP_ONCEPLUS:
+ kind = *ecode++ - OP_MAXPLUS;
+ min = 1, max = INT_MAX;
+ goto REPEATCHAR;
+
+ case OP_MAXQUERY:
+ case OP_MINQUERY:
+ case OP_ONCEQUERY:
+ kind = *ecode++ - OP_MAXQUERY;
+ min = 0, max = 1;
+
+ /* Common code for all repeated single-character matches. We can give
+ up quickly if there are fewer than the minimum number of characters left in
+ the subject. */
+
+ REPEATCHAR:
+ if (min > md->end_subject - eptr)
+ return FALSE;
+ c = *ecode++;
+
+ /* The code is duplicated for the caseless and caseful cases, for speed,
+ since matching characters is likely to be quite common. First, ensure the
+ minimum number of matches are present. If min = max, continue at the same
+ level without recursing. Otherwise, if minimizing, keep trying the rest of
+ the expression and advancing one matching character if failing, up to the
+ maximum. Alternatively, if maximizing, find the maximum number of
+ characters and work backwards. */
+
+ DPRINTF (("matching %c{%d,%d} against subject %.*s\n", c, min, max,
+ max, eptr));
+
+ if ((ims & PCRE_CASELESS) != 0)
+ {
+ c = md->lcc[c];
+ for (i = 1; i <= min; i++)
+ if (c != md->lcc[*eptr++])
+ return FALSE;
+ if (min == max)
+ continue;
+ if (kind == KIND_MIN)
+ {
+ for (i = min;; i++)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ if (i >= max || eptr >= md->end_subject ||
+ c != md->lcc[*eptr++])
+ return FALSE;
+ }
+ /* Control never gets here */
+ }
+ else
+ {
+ const uschar *pp = eptr;
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || c != md->lcc[*eptr])
+ break;
+ eptr++;
+ }
+
+ if (kind == KIND_MAX)
+ {
+ while (eptr >= pp)
+ if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ return FALSE;
+ }
+ }
+ }
+
+ /* Caseful comparisons */
+
+ else
+ {
+ for (i = 1; i <= min; i++)
+ if (c != *eptr++)
+ return FALSE;
+ if (min == max)
+ continue;
+ if (kind == KIND_MIN)
+ {
+ for (i = min;; i++)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ if (i >= max || eptr >= md->end_subject || c != *eptr++)
+ return FALSE;
+ }
+ /* Control never gets here */
+ }
+ else
+ {
+ const uschar *pp = eptr;
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || c != *eptr)
+ break;
+ eptr++;
+ }
+
+ if (kind == KIND_MAX)
+ {
+ while (eptr >= pp)
+ if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ return FALSE;
+ }
+ }
+ }
+
+ continue;
+
+ /* Match a negated single character */
+
+ case OP_NOT:
+ if (eptr >= md->end_subject)
+ return FALSE;
+ ecode++;
+ if ((ims & PCRE_CASELESS) != 0)
+ {
+ if (md->lcc[*ecode++] == md->lcc[*eptr++])
+ return FALSE;
+ }
+ else
+ {
+ if (*ecode++ == *eptr++)
+ return FALSE;
+ }
+ continue;
+
+ /* Match a negated single character repeatedly. This is almost a repeat of
+ the code for a repeated single character, but I haven't found a nice way of
+ commoning these up that doesn't require a test of the positive/negative
+ option for each character match. Maybe that wouldn't add very much to the
+ time taken, but character matching *is* what this is all about... */
+
+ case OP_NOTEXACT:
+ min = max = (ecode[1] << 8) + ecode[2];
+ ecode += 3;
+ goto REPEATNOTCHAR;
+
+ case OP_NOT_MAXUPTO:
+ case OP_NOT_MINUPTO:
+ case OP_NOT_ONCEUPTO:
+ min = 0;
+ max = (ecode[1] << 8) + ecode[2];
+ kind = *ecode - OP_NOT_MAXUPTO;
+ ecode += 3;
+ goto REPEATNOTCHAR;
+
+ case OP_NOT_MAXSTAR:
+ case OP_NOT_MINSTAR:
+ case OP_NOT_ONCESTAR:
+ kind = *ecode++ - OP_NOT_MAXSTAR;
+ min = 0, max = INT_MAX;
+ goto REPEATNOTCHAR;
+
+ case OP_NOT_MAXPLUS:
+ case OP_NOT_MINPLUS:
+ case OP_NOT_ONCEPLUS:
+ kind = *ecode++ - OP_NOT_MAXPLUS;
+ min = 1, max = INT_MAX;
+ goto REPEATNOTCHAR;
+
+ case OP_NOT_MAXQUERY:
+ case OP_NOT_MINQUERY:
+ case OP_NOT_ONCEQUERY:
+ kind = *ecode++ - OP_NOT_MAXQUERY;
+ min = 0, max = 1;
+
+ /* Common code for all repeated single-character matches. We can give
+ up quickly if there are fewer than the minimum number of characters left in
+ the subject. */
+
+ REPEATNOTCHAR:
+ if (min > md->end_subject - eptr)
+ return FALSE;
+ c = *ecode++;
+
+ /* The code is duplicated for the caseless and caseful cases, for speed,
+ since matching characters is likely to be quite common. First, ensure the
+ minimum number of matches are present. If min = max, continue at the same
+ level without recursing. Otherwise, if minimizing, keep trying the rest of
+ the expression and advancing one matching character if failing, up to the
+ maximum. Alternatively, if maximizing, find the maximum number of
+ characters and work backwards. */
+
+ DPRINTF (("negative matching %c{%d,%d} against subject %.*s\n", c, min, max,
+ max, eptr));
+
+ if ((ims & PCRE_CASELESS) != 0)
+ {
+ c = md->lcc[c];
+ for (i = 1; i <= min; i++)
+ if (c == md->lcc[*eptr++])
+ return FALSE;
+ if (min == max)
+ continue;
+ if (kind == KIND_MIN)
+ {
+ for (i = min;; i++)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ if (i >= max || eptr >= md->end_subject ||
+ c == md->lcc[*eptr++])
+ return FALSE;
+ }
+ /* Control never gets here */
+ }
+ else
+ {
+ const uschar *pp = eptr;
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || c == md->lcc[*eptr])
+ break;
+ eptr++;
+ }
+
+ if (kind == KIND_MAX)
+ {
+ while (eptr >= pp)
+ if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ return FALSE;
+ }
+ }
+ }
+
+ /* Caseful comparisons */
+
+ else
+ {
+ for (i = 1; i <= min; i++)
+ if (c == *eptr++)
+ return FALSE;
+ if (min == max)
+ continue;
+ if (kind == KIND_MIN)
+ {
+ for (i = min;; i++)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ if (i >= max || eptr >= md->end_subject || c == *eptr++)
+ return FALSE;
+ }
+ /* Control never gets here */
+ }
+ else
+ {
+ const uschar *pp = eptr;
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || c == *eptr)
+ break;
+ eptr++;
+ }
+
+ if (kind == KIND_MAX)
+ {
+ while (eptr >= pp)
+ if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ return FALSE;
+ }
+ }
+ }
+ continue;
+
+ /* Match a single character type repeatedly; several different opcodes
+ share code. This is very similar to the code for single characters, but we
+ repeat it in the interests of efficiency. */
+
+ case OP_TYPEEXACT:
+ min = max = (ecode[1] << 8) + ecode[2];
+ kind = OP_TYPE_ONCEUPTO - OP_TYPE_MAXUPTO;
+ ecode += 3;
+ goto REPEATTYPE;
+
+ case OP_TYPE_MAXUPTO:
+ case OP_TYPE_MINUPTO:
+ case OP_TYPE_ONCEUPTO:
+ min = 0;
+ max = (ecode[1] << 8) + ecode[2];
+ kind = *ecode - OP_TYPE_MAXUPTO;
+ ecode += 3;
+ goto REPEATTYPE;
+
+ case OP_TYPE_MAXSTAR:
+ case OP_TYPE_MINSTAR:
+ case OP_TYPE_ONCESTAR:
+ kind = *ecode++ - OP_TYPE_MAXSTAR;
+ min = 0, max = INT_MAX;
+ goto REPEATTYPE;
+
+ case OP_TYPE_MAXPLUS:
+ case OP_TYPE_MINPLUS:
+ case OP_TYPE_ONCEPLUS:
+ kind = *ecode++ - OP_TYPE_MAXPLUS;
+ min = 1, max = INT_MAX;
+ goto REPEATTYPE;
+
+ case OP_TYPE_MAXQUERY:
+ case OP_TYPE_MINQUERY:
+ case OP_TYPE_ONCEQUERY:
+ kind = *ecode++ - OP_TYPE_MAXQUERY;
+ min = 0, max = 1;
+
+ /* Common code for all repeated single character type matches */
+
+ REPEATTYPE:
+ ctype = 1 << *ecode++; /* Code for the character type */
+
+ /* First, ensure the minimum number of matches are present. Use inline
+ code for maximizing the speed, and do the type test once at the start
+ (i.e. keep it out of the loop). Also we can test that there are at least
+ the minimum number of bytes before we start. */
+
+ if (min > md->end_subject - eptr)
+ return FALSE;
+ if (min > 0)
+ {
+ for (i = 1; i <= min; i++)
+ if ((md->ctypes[*eptr++] & ctype) == 0)
+ return FALSE;
+ }
+
+ /* If min = max, continue at the same level without recursing */
+
+ if (min == max)
+ continue;
+
+ /* If minimizing, we have to test the rest of the pattern before each
+ subsequent match. */
+
+ if (kind == KIND_MIN)
+ {
+ for (i = min;; i++)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ if (i >= max || eptr >= md->end_subject)
+ return FALSE;
+
+ if ((md->ctypes[*eptr++] & ctype) == 0)
+ return FALSE;
+ }
+ /* Control never gets here */
+ }
+
+ /* If maximizing it is worth using inline code for speed, doing the type
+ test once at the start (i.e. keep it out of the loop). */
+
+ else
+ {
+ const uschar *pp = eptr;
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype) == 0)
+ break;
+ eptr++;
+ }
+
+
+ if (kind == KIND_MAX)
+ {
+ while (eptr >= pp)
+ {
+ if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ }
+ return FALSE;
+ }
+ }
+
+ continue;
+
+ /* Match a single character type repeatedly; several different opcodes
+ share code. This is very similar to the code for single characters, but we
+ repeat it in the interests of efficiency. */
+
+ case OP_TYPENOTEXACT:
+ min = max = (ecode[1] << 8) + ecode[2];
+ kind = OP_TYPENOT_ONCEUPTO - OP_TYPENOT_MAXUPTO;
+ ecode += 3;
+ goto REPEATTYPENOT;
+
+ case OP_TYPENOT_MAXUPTO:
+ case OP_TYPENOT_MINUPTO:
+ case OP_TYPENOT_ONCEUPTO:
+ min = 0;
+ max = (ecode[1] << 8) + ecode[2];
+ kind = *ecode - OP_TYPENOT_MAXUPTO;
+ ecode += 3;
+ goto REPEATTYPENOT;
+
+ case OP_TYPENOT_MAXSTAR:
+ case OP_TYPENOT_MINSTAR:
+ case OP_TYPENOT_ONCESTAR:
+ kind = *ecode++ - OP_TYPENOT_MAXSTAR;
+ min = 0, max = INT_MAX;
+ goto REPEATTYPENOT;
+
+ case OP_TYPENOT_MAXPLUS:
+ case OP_TYPENOT_MINPLUS:
+ case OP_TYPENOT_ONCEPLUS:
+ kind = *ecode++ - OP_TYPENOT_MAXPLUS;
+ min = 1, max = INT_MAX;
+ goto REPEATTYPENOT;
+
+ case OP_TYPENOT_MAXQUERY:
+ case OP_TYPENOT_MINQUERY:
+ case OP_TYPENOT_ONCEQUERY:
+ kind = *ecode++ - OP_TYPENOT_MAXQUERY;
+ min = 0, max = 1;
+
+ /* Common code for all repeated single character type matches */
+
+ REPEATTYPENOT:
+ ctype = *ecode++; /* Code for the character type */
+ if (ctype != 0 || !(ims & PCRE_DOTALL))
+ ctype = 1 << ctype;
+
+ /* First, ensure the minimum number of matches are present. Use inline
+ code for maximizing the speed, and do the type test once at the start
+ (i.e. keep it out of the loop). Also we can test that there are at least
+ the minimum number of bytes before we start. */
+
+ if (min > md->end_subject - eptr)
+ return FALSE;
+ if (min > 0)
+ {
+ for (i = 1; i <= min; i++)
+ if (md->ctypes[*eptr++] & ctype)
+ return FALSE;
+ }
+
+ /* If min = max, continue at the same level without recursing */
+
+ if (min == max)
+ continue;
+
+ /* If minimizing, we have to test the rest of the pattern before each
+ subsequent match. */
+
+ if (kind == KIND_MIN)
+ {
+ for (i = min;; i++)
+ {
+ if (match (eptr, ecode, offset_top, md, ims, eptrb, 0) != 0)
+ return TRUE;
+ if (i >= max || eptr >= md->end_subject)
+ return FALSE;
+
+ if (md->ctypes[*eptr++] & ctype)
+ return FALSE;
+ }
+ /* Control never gets here */
+ }
+
+ /* If maximizing it is worth using inline code for speed, doing the type
+ test once at the start (i.e. keep it out of the loop). */
+
+ else
+ {
+ const uschar *pp = eptr;
+ if (ctype == 0)
+ {
+ c = max - min;
+ if (c > md->end_subject - eptr)
+ c = md->end_subject - eptr;
+ eptr += c;
+ }
+ else
+ for (i = min; i < max; i++)
+ {
+ if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype))
+ break;
+ eptr++;
+ }
+
+ if (kind == KIND_MAX)
+ {
+ while (eptr >= pp)
+ {
+ if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
+ return TRUE;
+ }
+ return FALSE;
+ }
+ }
+
+ continue;
+
+ /* There's been some horrible disaster. */
+
+ default:
+ DPRINTF (("Unknown opcode %d\n", *ecode));
+ md->errorcode = PCRE_ERROR_UNKNOWN_NODE;
+ return FALSE;
+ }
+
+ /* Do not stick any code in here without much thought; it is assumed
+ that "continue" in the code above comes out to here to repeat the main
+ loop. */
+
+ } /* End of main loop */
+
+ /* Control never reaches here */
+}
+
+
+
+
+/*************************************************
+* Execute a Regular Expression *
+*************************************************/
+
+/* This function applies a compiled re to a subject string and picks out
+ portions of the string if it matches. Two elements in the vector are set for
+ each substring: the offsets to the start and end of the substring.
+
+ Arguments:
+ external_re points to the compiled expression
+ external_extra points to "hints" from pcre_study() or is NULL
+ subject points to the subject string
+ length length of subject string (may contain binary zeros)
+ start_offset where to start in the subject string
+ options option bits
+ offsets points to a vector of ints to be filled in with offsets
+ offsetcount the number of elements in the vector
+
+ Returns: > 0 => success; value is the number of elements filled in
+ = 0 => success, but offsets is not big enough
+ -1 => failed to match
+ < -1 => some kind of unexpected problem
+ */
+
+int
+pcre_exec (re, extra, subject, length, start_offset, options, offsets, offsetcount)
+ const pcre *re;
+ const pcre_extra *extra;
+ const char *subject;
+ int length;
+ int start_offset;
+ int options;
+ int *offsets;
+ int offsetcount;
+{
+ int resetcount, ocount;
+ int first_char = -1;
+ int req_char = -1;
+ int req_char2 = -1;
+ unsigned long int ims = 0;
+ match_data match_block;
+ const uschar *start_bits = NULL;
+ const uschar *bmtable = NULL;
+ const uschar *start_match;
+ const uschar *end_subject;
+ const uschar *req_char_ptr = start_match - 1;
+ BOOL using_temporary_offsets = FALSE;
+ BOOL anchored;
+ BOOL startline;
+
+ if ((options & ~PUBLIC_EXEC_OPTIONS) != 0)
+ return PCRE_ERROR_BADOPTION;
+
+ if (re == NULL || subject == NULL ||
+ (offsets == NULL && offsetcount > 0))
+ return PCRE_ERROR_NULL;
+ if (re->magic_number != MAGIC_NUMBER)
+ return PCRE_ERROR_BADMAGIC;
+
+ anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
+ startline = (re->options & PCRE_STARTLINE) != 0;
+
+ match_block.start_pattern = re->code;
+ match_block.start_subject = (const uschar *) subject;
+ match_block.end_subject = match_block.start_subject + length;
+ match_block.first_start = match_block.start_subject + start_offset;
+
+ match_block.endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
+
+ match_block.notbol = (options & PCRE_NOTBOL) != 0;
+ match_block.noteol = (options & PCRE_NOTEOL) != 0;
+ match_block.notempty = (options & PCRE_NOTEMPTY) != 0;
+
+ match_block.errorcode = PCRE_ERROR_NOMATCH; /* Default error */
+
+ match_block.lcc = re->tables + lcc_offset;
+ match_block.ctypes = re->tables + ctypes_offset;
+
+ start_match = match_block.first_start;
+ end_subject = match_block.end_subject;
+
+ /* For matches anchored to the end of the pattern, we can often avoid
+ analyzing most of the pattern. length > re->max_match_size is
+ implied in the second condition, because start_offset > 0. */
+
+ if (re->max_match_size >= 0
+ && length - re->max_match_size > start_offset)
+ start_match = (const uschar *) subject + length - re->max_match_size;
+
+ /* The ims options can vary during the matching as a result of the presence
+ of (?ims) items in the pattern. They are kept in a local variable so that
+ restoring at the exit of a group is easy. */
+
+ ims = re->options & (PCRE_CASELESS | PCRE_MULTILINE | PCRE_DOTALL);
+
+ /* Set up the first character to match, if available. The first_char value is
+ never set for an anchored regular expression, but the anchoring may be forced
+ at run time, so we have to test for anchoring. The first char may be unset for
+ an unanchored pattern, of course. If there's no first char and the pattern was
+ studied, there may be a bitmap of possible first characters. */
+
+ if (!anchored)
+ {
+ if ((re->options & PCRE_FIRSTSET) != 0)
+ {
+ first_char = re->first_char;
+ if ((ims & PCRE_CASELESS) != 0)
+ first_char = match_block.lcc[first_char];
+ }
+ if (!startline && extra != NULL)
+ {
+ if ((extra->options & PCRE_STUDY_MAPPED) != 0)
+ start_bits = extra->data.start_bits;
+ else if ((extra->options & PCRE_STUDY_BM) != 0)
+ {
+ bmtable = extra->data.bmtable;
+ if (start_match + bmtable[256] > end_subject)
+ return PCRE_ERROR_NOMATCH;
+ }
+ }
+ }
+
+ /* If the expression has got more back references than the offsets supplied can
+ hold, we get a temporary bit of working store to use during the matching.
+ Otherwise, we can use the vector supplied, rounding down its size to a multiple
+ of 3. */
+
+ ocount = offsetcount - (offsetcount % 3);
+
+ if (re->top_backref > 0 && re->top_backref >= ocount / 3)
+ {
+ ocount = re->top_backref * 3 + 3;
+ match_block.offset_vector = (int *) (pcre_malloc) (ocount * sizeof (int));
+ if (match_block.offset_vector == NULL)
+ return PCRE_ERROR_NOMEMORY;
+ using_temporary_offsets = TRUE;
+ DPRINTF (("Got memory to hold back references\n"));
+ }
+ else
+ match_block.offset_vector = offsets;
+
+ match_block.offset_end = ocount;
+ match_block.offset_max = (2 * ocount) / 3;
+ match_block.offset_overflow = FALSE;
+
+ /* Compute the minimum number of offsets that we need to reset each time. Doing
+ this makes a huge difference to execution time when there aren't many brackets
+ in the pattern. */
+ resetcount = 2 + re->top_bracket * 2;
+ if (resetcount > offsetcount)
+ resetcount = ocount;
+
+ /* Reset the working variable associated with each extraction. These should
+ never be used unless previously set, but they get saved and restored, and so we
+ initialize them to avoid reading uninitialized locations. */
+ if (match_block.offset_vector != NULL)
+ {
+ register int *iptr = match_block.offset_vector + ocount;
+ register int *iend = iptr - resetcount / 2 + 1;
+ while (--iptr >= iend)
+ *iptr = -1;
+ }
+
+ /* For anchored or unanchored matches, there may be a "last known required
+ character" set. If the PCRE_CASELESS is set, implying that the match starts
+ caselessly, or if there are any changes of this flag within the regex, set up
+ both cases of the character. Otherwise set the two values the same, which will
+ avoid duplicate testing (which takes significant time). This covers the vast
+ majority of cases. It will be suboptimal when the case flag changes in a regex
+ and the required character in fact is caseful. */
+ if ((re->options & PCRE_REQCHSET) != 0)
+ {
+ req_char = re->req_char;
+ req_char2 = ((re->options & (PCRE_CASELESS | PCRE_ICHANGED)) != 0) ?
+ (re->tables + fcc_offset)[req_char] : req_char;
+ }
+
+ /* Loop for handling unanchored repeated matching attempts; for anchored regexs
+ the loop runs just once. */
+ do
+ {
+ int rc;
+ register int *iptr = match_block.offset_vector;
+ register int *iend = iptr + resetcount;
+#ifdef DEBUG
+ int skipped_chars = 0;
+#endif
+
+ /* Reset the maximum number of extractions we might see. */
+
+ while (iptr < iend)
+ *iptr++ = -1;
+
+ /* Advance to a possible match for an initial string after study */
+
+ if (bmtable != NULL)
+ {
+#ifdef DEBUG
+ skipped_chars += bmtable[256] - 1;
+#endif
+ start_match += bmtable[256] - 1;
+ while (start_match < end_subject)
+ {
+ if (bmtable[*start_match])
+#ifdef DEBUG
+ skipped_chars += bmtable[*start_match],
+#endif
+ start_match += bmtable[*start_match];
+ else
+ {
+#ifdef DEBUG
+ skipped_chars -= bmtable[256] - 1;
+#endif
+ start_match -= bmtable[256] - 1;
+ break;
+ }
+ }
+ }
+
+ /* Or to a unique first char if possible */
+
+ else if (first_char >= 0)
+ {
+ if ((ims & PCRE_CASELESS) != 0)
+ while (start_match < end_subject &&
+ match_block.lcc[*start_match] != first_char)
+#ifdef DEBUG
+ skipped_chars++,
+#endif
+ start_match++;
+ else
+ while (start_match < end_subject && *start_match != first_char)
+#ifdef DEBUG
+ skipped_chars++,
+#endif
+ start_match++;
+ }
+
+ /* Or to just after \n for a multiline match if possible */
+
+ else if (startline)
+ {
+ if (start_match > match_block.start_subject + start_offset)
+ {
+ while (start_match < end_subject && start_match[-1] != '\n')
+#ifdef DEBUG
+ skipped_chars++,
+#endif
+ start_match++;
+ }
+ }
+
+ /* Or to a non-unique first char after study */
+
+ else if (start_bits != NULL)
+ {
+ while (start_match < end_subject)
+ {
+ register int c = *start_match;
+ if ((start_bits[c / 8] & (1 << (c & 7))) == 0)
+#ifdef DEBUG
+ skipped_chars++,
+#endif
+ start_match++;
+ else
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ if (skipped_chars)
+ printf (">>>>> Skipped %d chars to reach first character\n",
+ skipped_chars);
+ printf (">>>> Match against: ");
+ pchars (start_match, end_subject - start_match, TRUE, &match_block);
+ printf ("\n");
+#endif
+
+ /* If req_char is set, we know that that character must appear in the subject
+ for the match to succeed. If the first character is set, req_char must be
+ later in the subject; otherwise the test starts at the match point. This
+ optimization can save a huge amount of backtracking in patterns with nested
+ unlimited repeats that aren't going to match. We don't know what the state of
+ case matching may be when this character is hit, so test for it in both its
+ cases if necessary. However, the different cased versions will not be set up
+ unless PCRE_CASELESS was given or the casing state changes within the regex.
+ Writing separate code makes it go faster, as does using an autoincrement and
+ backing off on a match. */
+
+ if (req_char >= 0)
+ {
+ register const uschar *p = start_match + ((first_char >= 0) ? 1 : 0);
+
+ /* We don't need to repeat the search if we haven't yet reached the
+ place we found it at last time. */
+
+ if (p > req_char_ptr)
+ {
+ /* Do a single test if no case difference is set up */
+
+ if (req_char == req_char2)
+ {
+ while (p < end_subject)
+ {
+ if (*p++ == req_char)
+ {
+ p--;
+ break;
+ }
+ }
+ }
+
+ /* Otherwise test for either case */
+
+ else
+ {
+ while (p < end_subject)
+ {
+ register int pp = *p++;
+ if (pp == req_char || pp == req_char2)
+ {
+ p--;
+ break;
+ }
+ }
+ }
+
+ /* If we can't find the required character, break the matching loop */
+
+ if (p >= end_subject)
+ break;
+
+ /* If we have found the required character, save the point where we
+ found it, so that we don't search again next time round the loop if
+ the start hasn't passed this character yet. */
+
+ req_char_ptr = p;
+ }
+ }
+
+ /* When a match occurs, substrings will be set for all internal extractions;
+ we just need to set up the whole thing as substring 0 before returning. If
+ there were too many extractions, set the return code to zero. In the case
+ where we had to get some local store to hold offsets for backreferences, copy
+ those back references that we can. In this case there need not be overflow
+ if certain parts of the pattern were not used. */
+
+ match_block.start_match = start_match;
+ if (!match (start_match, re->code, 2, &match_block, ims, NULL, match_isgroup))
+ continue;
+
+ /* Copy the offset information from temporary store if necessary */
+
+ if (using_temporary_offsets)
+ {
+ if (offsetcount >= 4)
+ {
+ memcpy (offsets + 2, match_block.offset_vector + 2,
+ (offsetcount - 2) * sizeof (int));
+ DPRINTF (("Copied offsets from temporary memory\n"));
+ }
+ if (match_block.end_offset_top > offsetcount)
+ match_block.offset_overflow = TRUE;
+
+ DPRINTF (("Freeing temporary memory\n"));
+ (pcre_free) (match_block.offset_vector);
+ }
+
+ rc = match_block.offset_overflow ? 0 : match_block.end_offset_top / 2;
+
+ if (offsetcount < 2)
+ rc = 0;
+ else
+ {
+ offsets[0] = start_match - match_block.start_subject;
+ offsets[1] = match_block.end_match_ptr - match_block.start_subject;
+ }
+
+ DPRINTF ((">>>> returning %d\n", rc));
+ return rc;
+ }
+
+ /* This "while" is the end of the "do" above */
+ while (!anchored &&
+ match_block.errorcode == PCRE_ERROR_NOMATCH &&
+ start_match++ < end_subject);
+
+ if (using_temporary_offsets)
+ {
+ DPRINTF (("Freeing temporary memory\n"));
+ (pcre_free) (match_block.offset_vector);
+ }
+
+ DPRINTF ((">>>> returning %d\n", match_block.errorcode));
+
+ return match_block.errorcode;
+}
diff --git a/pcre/regexp.c b/pcre/regexp.c
new file mode 100644
index 0000000..24d7901
--- /dev/null
+++ b/pcre/regexp.c
@@ -0,0 +1,381 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ This module is a wrapper that provides a POSIX API to the underlying PCRE
+ functions.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+#include "internal.h"
+#include "regexp.h"
+#include "stdlib.h"
+
+
+/* Corresponding tables of PCRE error messages and POSIX error codes. */
+
+const char *pcre_estrings[] =
+{
+ "",
+ N_("\\ at end of pattern"),
+ N_("\\c at end of pattern"),
+ N_("unrecognized character follows \\"),
+ N_("numbers out of order in {} quantifier"),
+ N_("number too big in {} quantifier"),
+ N_("missing terminating ] for character class"),
+ N_("invalid escape sequence in character class"),
+ N_("range out of order in character class"),
+ N_("nothing to repeat"),
+ N_("operand of unlimited repeat could match the empty string"),
+ N_("internal error: unexpected repeat"),
+ N_("unrecognized character after (?"),
+ N_("unused error"),
+ N_("unmatched braces"),
+ N_("back reference to non-existent subpattern"),
+ N_("erroffset passed as NULL"),
+ N_("unknown option bit(s) set"),
+ N_("missing ) after comment"),
+ N_("parentheses nested too deeply"),
+ N_("regular expression too large"),
+ N_("failed to get memory"),
+ N_("unmatched parentheses"),
+ N_("internal error: code overflow"),
+ N_("unrecognized character after (?<"),
+ N_("lookbehind assertion is not fixed length"),
+ N_("malformed number after (?("),
+ N_("conditional group contains more than two branches"),
+ N_("assertion expected after (?("),
+ N_("(?p must be followed by )"),
+ N_("unknown POSIX class name"),
+ N_("POSIX collating elements are not supported"),
+ N_("bad condition (?(0)")
+};
+
+static int eint[] =
+{
+ 0,
+ REG_EESCAPE, /* \\ at end of pattern */
+ REG_EESCAPE, /* \\c at end of pattern */
+ REG_EESCAPE, /* unrecognized character follows \\ */
+ REG_BADBR, /* numbers out of order in {} quantifier */
+ REG_BADBR, /* number too big in {} quantifier */
+ REG_EBRACK, /* missing terminating ] for character class */
+ REG_ECTYPE, /* invalid escape sequence in character class */
+ REG_ERANGE, /* range out of order in character class */
+ REG_BADRPT, /* nothing to repeat */
+ REG_BADRPT, /* operand of unlimited repeat could match the empty string */
+ REG_ASSERT, /* internal error: unexpected repeat */
+ REG_BADPAT, /* unrecognized character after (? */
+ REG_ASSERT, /* unused error */
+ REG_EPAREN, /* missing ) */
+ REG_ESUBREG, /* back reference to non-existent subpattern */
+ REG_INVARG, /* erroffset passed as NULL */
+ REG_INVARG, /* unknown option bit(s) set */
+ REG_EPAREN, /* missing ) after comment */
+ REG_ESIZE, /* parentheses nested too deeply */
+ REG_ESIZE, /* regular expression too large */
+ REG_ESPACE, /* failed to get memory */
+ REG_EPAREN, /* unmatched brackets */
+ REG_ASSERT, /* internal error: code overflow */
+ REG_BADPAT, /* unrecognized character after (?< */
+ REG_BADPAT, /* lookbehind assertion is not fixed length */
+ REG_BADPAT, /* malformed number after (?( */
+ REG_BADPAT, /* conditional group containe more than two branches */
+ REG_BADPAT, /* assertion expected after (?( */
+ REG_BADPAT, /* (?p must be followed by ) */
+ REG_ECTYPE, /* unknown POSIX class name */
+ REG_BADPAT, /* POSIX collating elements are not supported */
+ REG_BADPAT, /* character value in \x{...} sequence is too large */
+ REG_BADPAT /* invalid condition (?(0) */
+};
+
+/* Table of texts corresponding to POSIX error codes */
+
+static const char *pstring[] =
+{
+ "",
+ N_("internal error"),
+ N_("invalid repeat counts in {}"),
+ N_("pattern error"),
+ N_("nothing to repeat"),
+ N_("unmatched braces"),
+ N_("missing terminating ] for character class"),
+ N_("bad collating element"),
+ N_("unknown POSIX class name"),
+ N_("bad escape sequence"),
+ N_("empty expression"),
+ N_("unmatched parentheses"),
+ N_("range out of order in character class"),
+ N_("regular expression too large"),
+ N_("failed to get memory"),
+ N_("back reference to non-existent subpattern"),
+ N_("bad argument"),
+ N_("match failed")
+};
+
+
+
+
+/*************************************************
+* Translate PCRE text code to int *
+*************************************************/
+
+/* PCRE compile-time errors are given as strings defined as macros. We can just
+ look them up in a table to turn them into POSIX-style error codes. */
+
+static int
+pcre_posix_error_code (s)
+ const char *s;
+{
+ size_t i;
+ for (i = 1; i < sizeof (pcre_estrings) / sizeof (char *); i++)
+ if (strcmp (s, pcre_estrings[i]) == 0)
+ return eint[i];
+ return REG_ASSERT;
+}
+
+
+
+/*************************************************
+* Translate error code to string *
+*************************************************/
+
+size_t
+regerror (errcode, preg, errbuf, errbuf_size)
+ int errcode;
+ const regex_t *preg;
+ char *errbuf;
+ size_t errbuf_size;
+{
+ const char *message, *addmessage;
+ size_t size;
+
+ message = (errcode >= (int) (sizeof (pstring) / sizeof (char *))) ?
+ _("unknown error code") : gettext(pstring[errcode]);
+
+ addmessage = _("%s at offset %-6d");
+
+ if (errbuf_size > 0)
+ {
+ if (preg != NULL && (int) preg->re_erroffset != -1)
+ size = snprintf (errbuf, errbuf_size - 1, addmessage,
+ message, (int) preg->re_erroffset);
+ else
+ strncpy (errbuf, message, errbuf_size - 1);
+ }
+
+ errbuf[errbuf_size - 1] = 0;
+ return strlen(errbuf);
+}
+
+
+
+
+/*************************************************
+* Free store held by a regex *
+*************************************************/
+
+void
+regfree (preg)
+ regex_t *preg;
+{
+ (pcre_free) (preg->re_pcre);
+}
+
+
+
+
+/*************************************************
+* Compile a regular expression *
+*************************************************/
+
+/*
+ Arguments:
+ preg points to a structure for recording the compiled expression
+ pattern the pattern to compile
+ cflags compilation flags
+
+ Returns: 0 on success
+ various non-zero codes on failure
+ */
+
+int
+regcomp (preg, pattern, cflags)
+ regex_t *preg;
+ const char *pattern;
+ int cflags;
+{
+ return regncomp (preg, pattern, (int) strlen (pattern), cflags);
+}
+
+int
+regncomp (preg, pattern, length, cflags)
+ regex_t *preg;
+ const char *pattern;
+ int length, cflags;
+{
+ const char *errptr;
+ int errofs;
+ int options = PCRE_ENGLISH_ERRORS;
+
+ options |= (cflags & REG_ICASE) ? PCRE_CASELESS : 0;
+ options |= (cflags & REG_EXTENDED) ? PCRE_EXTENDED : 0;
+
+ if ((cflags & REG_PERL) != 0)
+ {
+ options |= (cflags & REG_NEWLINE) ? PCRE_MULTILINE : 0;
+ options |= (cflags & REG_DOTALL) ? PCRE_DOTALL : 0;
+ preg->re_pcre = pcre_compile_nuls (pattern, length, options,
+ &errptr, &errofs, NULL);
+ }
+ else
+ {
+ options |= (cflags & REG_NEWLINE) ? PCRE_MULTILINE : PCRE_DOTALL;
+ preg->re_pcre = pcre_posix_compile_nuls (pattern, length, options,
+ &errptr, &errofs, NULL);
+ }
+
+ preg->re_erroffset = errofs;
+
+ if (preg->re_pcre == NULL)
+ return pcre_posix_error_code (errptr);
+
+ preg->re_study = pcre_study (preg->re_pcre, 0, &errptr);
+
+ pcre_info (preg->re_pcre, preg->re_study,
+ PCRE_INFO_CAPTURECOUNT, &preg->re_nsub);
+ return 0;
+}
+
+
+
+
+/*************************************************
+* Match a regular expression *
+*************************************************/
+
+int
+regexec (preg, string, nmatch, pmatch, eflags)
+ regex_t *preg;
+ const char *string;
+ size_t nmatch;
+ regmatch_t pmatch[];
+ int eflags;
+{
+
+ if (eflags & REG_STARTEND)
+ return regnexec (preg, string, 0, nmatch, pmatch, eflags);
+ else
+ return regnexec (preg, string, (int) strlen (string),
+ nmatch, pmatch, eflags);
+}
+
+int
+regnexec (preg, string, length, nmatch, pmatch, eflags)
+ regex_t *preg;
+ const char *string;
+ int length;
+ size_t nmatch;
+ regmatch_t pmatch[];
+ int eflags;
+{
+ int start;
+ int rc;
+ int options;
+ int *ovector = NULL;
+
+ if (eflags & REG_STARTEND)
+ {
+ start = pmatch[0].rm_so;
+ length = pmatch[0].rm_eo;
+ }
+ else
+ start = 0;
+
+ options =
+ ((eflags & REG_NOTBOL) ? PCRE_NOTBOL : 0) |
+ ((eflags & REG_NOTEOL) ? PCRE_NOTEOL : 0);
+
+ preg->re_erroffset = (size_t) (-1); /* Only has meaning after compile */
+
+ /* Unfortunately, PCRE requires 3 ints of working space for each captured
+ substring, so we have to get and release working store instead of just using
+ the POSIX structures as was done in earlier releases when PCRE needed only 2
+ ints. */
+
+ ovector = (int *) (pcre_malloc) (sizeof (int) * (preg->re_nsub * 3 + 3));
+ if (ovector == NULL)
+ return REG_ESPACE;
+
+ rc = pcre_exec (preg->re_pcre, preg->re_study, string, length,
+ start, options, ovector, preg->re_nsub * 3 + 3);
+
+ if (rc > 0)
+ {
+ size_t i, max;
+ max = rc < nmatch ? rc : nmatch;
+
+ for (i = 0; i < max; i++)
+ {
+ pmatch[i].rm_so = ovector[i * 2];
+ pmatch[i].rm_eo = ovector[i * 2 + 1];
+ }
+ for (; i < nmatch; i++)
+ pmatch[i].rm_so = pmatch[i].rm_eo = -1;
+
+ (pcre_free) (ovector);
+ return 0;
+ }
+
+ else
+ {
+ (pcre_free) (ovector);
+ switch (rc)
+ {
+ case PCRE_ERROR_NOMATCH:
+ return REG_NOMATCH;
+ case PCRE_ERROR_NULL:
+ return REG_INVARG;
+ case PCRE_ERROR_BADOPTION:
+ return REG_INVARG;
+ case PCRE_ERROR_BADMAGIC:
+ return REG_INVARG;
+ case PCRE_ERROR_UNKNOWN_NODE:
+ return REG_ASSERT;
+ case PCRE_ERROR_NOMEMORY:
+ return REG_ESPACE;
+ default:
+ return REG_ASSERT;
+ }
+ }
+}
+
+
diff --git a/pcre/regexp.h b/pcre/regexp.h
new file mode 100644
index 0000000..fe5ef38
--- /dev/null
+++ b/pcre/regexp.h
@@ -0,0 +1,107 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/* Copyright (c) 1997-2000 University of Cambridge */
+
+#ifndef _PCREPOSIX_H
+#define _PCREPOSIX_H
+
+/* This is the header for the POSIX wrapper interface to the PCRE Perl-
+ Compatible Regular Expression library. It defines the things POSIX says should
+ be there. I hope. */
+
+/* Have to include stdlib.h in order to ensure that size_t is defined. */
+
+#include
+
+/* Allow for C++ users */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef __STDC__
+#define __PCRE_PROTO(a) a
+#else
+#define __PCRE_PROTO(a) ()
+#endif
+
+/* Options defined by POSIX. */
+
+#define REG_ICASE 0x01
+#define REG_NEWLINE 0x02
+#define REG_NOTBOL 0x04
+#define REG_NOTEOL 0x08
+#define REG_EXTENDED 0x10
+
+#define REG_PERL 0x20
+#define REG_DOTALL 0x40
+#define REG_STARTEND 0x80
+
+/* These are not used by PCRE, but by defining them we make it easier
+ to slot PCRE into existing programs that make POSIX calls. */
+
+#define REG_NOSUB 0
+
+/* Error values. Not all these are relevant or used by the wrapper. */
+
+enum {
+ REG_ASSERT = 1, /* internal error ? */
+ REG_BADBR, /* invalid repeat counts in {} */
+ REG_BADPAT, /* pattern error */
+ REG_BADRPT, /* ? * + invalid */
+ REG_EBRACE, /* unbalanced {} */
+ REG_EBRACK, /* unbalanced [] */
+ REG_ECOLLATE, /* collation error - not relevant */
+ REG_ECTYPE, /* bad class */
+ REG_EESCAPE, /* bad escape sequence */
+ REG_EMPTY, /* empty expression */
+ REG_EPAREN, /* unbalanced () */
+ REG_ERANGE, /* bad range inside [] */
+ REG_ESIZE, /* expression too big */
+ REG_ESPACE, /* failed to get memory */
+ REG_ESUBREG, /* bad back reference */
+ REG_INVARG, /* bad argument */
+ REG_NOMATCH /* match failed */
+};
+
+
+/* The structure representing a compiled regular expression. */
+
+typedef struct
+{
+ void *re_pcre;
+ void *re_study;
+ size_t re_nsub;
+ size_t re_erroffset;
+} regex_t;
+
+/* The structure in which a captured offset is returned. */
+
+typedef int regoff_t;
+
+typedef struct
+{
+ regoff_t rm_so;
+ regoff_t rm_eo;
+} regmatch_t;
+
+/* The functions */
+
+extern int regcomp __PCRE_PROTO ((regex_t *, const char *, int));
+extern int regncomp __PCRE_PROTO ((regex_t *, const char *, int, int));
+extern int regexec __PCRE_PROTO ((regex_t *, const char *, size_t,
+ regmatch_t *, int));
+extern int regnexec __PCRE_PROTO ((regex_t *, const char *, int, size_t,
+ regmatch_t *, int));
+extern size_t regerror __PCRE_PROTO ((int, const regex_t *, char *, size_t));
+extern void regfree __PCRE_PROTO ((regex_t *));
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+#undef __PCRE_PROTO
+
+#endif
diff --git a/pcre/reginfo.c b/pcre/reginfo.c
new file mode 100644
index 0000000..48e0323
--- /dev/null
+++ b/pcre/reginfo.c
@@ -0,0 +1,111 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+#include "internal.h"
+
+/*************************************************
+* Return info about compiled pattern *
+*************************************************/
+
+/* This is a newer "info" function which has an extensible interface so
+ that additional items can be added compatibly.
+
+ Arguments:
+ external_re points to compiled code
+ external_study points to study data, or NULL
+ what what information is required
+ where where to put the information
+
+ Returns: 0 if data returned, negative on error
+ */
+
+int
+pcre_info (re, study, what, where)
+ const pcre *re;
+ const pcre_extra *study;
+ int what;
+ void *where;
+{
+ if (re == NULL || where == NULL)
+ return PCRE_ERROR_NULL;
+ if (re->magic_number != MAGIC_NUMBER)
+ return PCRE_ERROR_BADMAGIC;
+
+ switch (what)
+ {
+ case PCRE_INFO_OPTIONS:
+ *((unsigned long int *) where) = re->options & PUBLIC_OPTIONS;
+ break;
+
+ case PCRE_INFO_SIZE:
+ *((size_t *) where) = re->size;
+ break;
+
+ case PCRE_INFO_CAPTURECOUNT:
+ *((int *) where) = re->top_bracket;
+ break;
+
+ case PCRE_INFO_BACKREFMAX:
+ *((int *) where) = re->top_backref;
+ break;
+
+ case PCRE_INFO_FIRSTCHAR:
+ *((int *) where) =
+ ((re->options & PCRE_FIRSTSET) != 0) ? re->first_char :
+ ((re->options & PCRE_STARTLINE) != 0) ? -1 : -2;
+ break;
+
+ case PCRE_INFO_BMTABLE:
+ *((const uschar **) where) =
+ (study != NULL && (study->options & PCRE_STUDY_BM) != 0) ?
+ study->data.bmtable : NULL;
+ break;
+
+ case PCRE_INFO_FIRSTTABLE:
+ *((const uschar **) where) =
+ (study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0) ?
+ study->data.start_bits : NULL;
+ break;
+
+ case PCRE_INFO_LASTLITERAL:
+ *((int *) where) =
+ ((re->options & PCRE_REQCHSET) != 0) ? re->req_char : -1;
+ break;
+
+ default:
+ return PCRE_ERROR_BADOPTION;
+ }
+
+ return 0;
+}
diff --git a/pcre/regperl.c b/pcre/regperl.c
new file mode 100644
index 0000000..dfad38c
--- /dev/null
+++ b/pcre/regperl.c
@@ -0,0 +1,2261 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+
+/* Include the internals header, which itself includes Standard C headers plus
+ the external pcre header. */
+
+#include "internal.h"
+
+/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
+ inline, and there are *still* stupid compilers about that don't like indented
+ pre-processor statements. I suppose it's only been 10 years... */
+
+#ifdef DEBUG
+#define DPRINTF(p) printf p
+#define DFWRITE(p) fwrite p
+#else
+#define DPRINTF(p) /*nothing */
+#define DFWRITE(p) /*nothing */
+#endif
+
+
+
+/* Allow compilation as C++ source code, should anybody want to do that. */
+
+#ifdef __cplusplus
+#define class pcre_class
+#endif
+
+
+/* Maximum number of items on the nested bracket stacks at compile time. This
+ applies to the nesting of all kinds of parentheses. It does not limit
+ un-nested, non-capturing parentheses. This number can be made bigger if
+ necessary - it is used to dimension one int and one unsigned char vector at
+ compile time. */
+
+#define BRASTACK_SIZE 200
+
+
+/* The number of bytes in a literal character string above which we can't
+ add any more. */
+
+#define MAXLIT 255
+
+
+/* Table for handling escaped characters in the range '0'-'z'. Positive returns
+ are simple data values; negative values are for special things like \d and so
+ on. Zero means further processing is needed (for things like \x), or the escape
+ is invalid. */
+
+static const short int escapes[] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 7 */
+ 0, 0, ':', ';', '<', '=', '>', '?', /* 8 - ? */
+ '@', -ESC_A, -ESC_B, 0, -ESC_D, 0, 0, -ESC_G, /* @ - G */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
+ 0, 0, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */
+ 0, 0, -ESC_Z, '[', '\\', ']', '^', '_', /* X - _ */
+ '`', 7, -ESC_b, 0, -ESC_d, 27, '\f', 0, /* ` - g */
+ 0, 0, 0, 0, 0, 0, '\n', 0, /* h - o */
+ 0, 0, '\r', -ESC_s, '\t', 0, 0, -ESC_w, /* p - w */
+ 0, 0, -ESC_z /* x - z */
+};
+
+
+
+/*************************************************
+* Global variables *
+*************************************************/
+
+/* PCRE is thread-clean and doesn't use any global variables in the normal
+ sense. However, it calls memory allocation and free functions via the two
+ indirections below, which are can be changed by the caller, but are shared
+ between all threads. */
+
+void *(*pcre_malloc) (size_t) = malloc;
+void (*pcre_free) (void *) = free;
+
+#include "regcomp.c"
+
+/*************************************************
+* Handle escapes *
+*************************************************/
+
+/* This function is called when a \ has been encountered. It either returns a
+ positive value for a simple escape such as \n, or a negative value which
+ encodes one of the more complicated things such as \d. On entry, ptr is
+ pointing at the \. On exit, it is on the final character of the escape
+ sequence.
+
+ Arguments:
+ ptrptr points to the pattern position pointer
+ errorptr points to the pointer to the error message
+ bracount number of previous capturing brackets
+ options the options bits
+ isclass TRUE if inside a character class
+ cd pointer to char tables block
+
+ Returns: zero or positive => a data character
+ negative => a special escape sequence
+ on error, errorptr is set
+ */
+
+static int
+check_escape (ptrptr, errorptr, bracount, options, isclass, cd)
+ const uschar **ptrptr;
+ const char **errorptr;
+ int bracount;
+ int options;
+ BOOL isclass;
+ compile_data *cd;
+{
+ const uschar *ptr = *ptrptr;
+ int c, i;
+
+ c = *(++ptr);
+
+ /* Digits or letters may have special meaning; all others are literals. */
+ if (c < '0' || c > 'z')
+ {
+ }
+
+ /* Do an initial lookup in a table. A non-zero result is something that can be
+ returned immediately. Otherwise further processing may be required. */
+ else if ((i = escapes[c - '0']) != 0)
+ c = i;
+
+ /* Escapes that need further processing, or are illegal. */
+ else
+ {
+ const uschar *oldptr;
+ switch (c)
+ {
+ /* The handling of escape sequences consisting of a string of digits
+ starting with one that is not zero is not straightforward. By experiment,
+ the way Perl works seems to be as follows:
+
+ Outside a character class, the digits are read as a decimal number. If the
+ number is less than 10, or if there are that many previous capturing
+ left brackets, then it is a back reference. Otherwise, up to three octal
+ digits are read to form an escaped byte. Thus \123 is likely to be octal
+ 123 (cf \0123, which is octal 012 followed by the literal 3). If the octal
+ value is greater than 377, the least significant 8 bits are taken. Inside a
+ character class, \ followed by a digit is always an octal number. */
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+
+ if (!isclass)
+ {
+ oldptr = ptr;
+ c -= '0';
+ while (ptr < cd->end && (cd->ctypes[ptr[1]] & ctype_digit) != 0)
+ c = c * 10 + *(++ptr) - '0';
+ if (c < 10 || c <= bracount)
+ {
+ c = -(ESC_REF + c);
+ break;
+ }
+ ptr = oldptr; /* Put the pointer back and fall through */
+ }
+
+ /* Handle an octal number following \. If the first digit is 8 or 9, Perl
+ generates a binary zero byte and treats the digit as a following literal.
+ Thus we have to pull back the pointer by one. */
+
+ if ((c = *ptr) >= '8')
+ {
+ ptr--;
+ c = 0;
+ break;
+ }
+
+ /* \0 always starts an octal number, but we may drop through to here with a
+ larger first octal digit. */
+
+ case '0':
+ c -= '0';
+ while (i++ < 2 && ptr < cd->end &&
+ (cd->ctypes[ptr[1]] & ctype_digit) != 0 &&
+ ptr[1] != '8' && ptr[1] != '9')
+ c = c * 8 + *(++ptr) - '0';
+ c &= 255; /* Take least significant 8 bits */
+ break;
+
+ case 'x':
+ /* Read just a single hex char */
+
+ c = 0;
+ while (i++ < 2 && ptr < cd->end &&
+ (cd->ctypes[ptr[1]] & ctype_xdigit) != 0)
+ {
+ ptr++;
+ c = c * 16 + cd->lcc[*ptr] -
+ (((cd->ctypes[*ptr] & ctype_digit) != 0) ? '0' : 'W');
+ }
+ break;
+
+ /* Other special escapes not starting with a digit are straightforward */
+
+ case 'c':
+ if ((++ptr) > cd->end || (c = *ptr) == 0)
+ {
+ *errorptr = pcre_estrings[2];
+ return 0;
+ }
+
+ /* A letter is upper-cased; then the 0x40 bit is flipped */
+
+ if (c >= 'a' && c <= 'z')
+ c = cd->fcc[c];
+ c ^= 0x40;
+ break;
+
+ /* PCRE_EXTRA enables extensions to Perl in the matter of escapes. Any
+ other alphameric following \ is an error if PCRE_EXTRA was set; otherwise,
+ for Perl compatibility, it is a literal. This code looks a bit odd, but
+ there used to be some cases other than the default, and there may be again
+ in future, so I haven't "optimized" it. */
+
+ default:
+ if ((options & PCRE_EXTRA) != 0)
+ switch (c)
+ {
+ default:
+ *errorptr = pcre_estrings[3];
+ break;
+ }
+ break;
+ }
+ }
+
+ *ptrptr = ptr;
+ return c;
+}
+
+
+/*************************************************
+* Compile one branch *
+*************************************************/
+
+/* Scan the pattern, compiling it into the code vector.
+
+ Arguments:
+ options the option bits
+ brackets points to number of capturing brackets used
+ code points to the pointer to the current code point
+ ptrptr points to the current pattern pointer
+ errorptr points to pointer to error message
+ optchanged set to the value of the last OP_OPT item compiled
+ reqchar set to the last literal character required, else -1
+ countlits set to count of mandatory literal characters
+ cd contains pointers to tables
+
+ Returns: TRUE on success
+ FALSE, with *errorptr set on error
+ */
+
+static BOOL
+compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, reqchar, countlits, cd)
+ int options;
+ int *brackets;
+ uschar **codeptr;
+ const uschar **ptrptr;
+ const char **errorptr;
+ int *optchanged;
+ int *reqchar;
+ int *countlits;
+ compile_data *cd;
+{
+ int repeat_type, op_type;
+ int repeat_min, repeat_max;
+ int bravalue, length;
+ int greedy_default, greedy_non_default;
+ int prevreqchar;
+ int condcount = 0;
+ int subcountlits = 0;
+ register int c;
+ register uschar *code = *codeptr;
+ uschar *tempcode;
+ const uschar *ptr = *ptrptr;
+ const uschar *tempptr;
+ uschar *previous = NULL;
+ uschar class[32];
+
+ /* Set up the default and non-default settings for greediness */
+ greedy_default = ((options & PCRE_UNGREEDY) != 0);
+ greedy_non_default = greedy_default ^ 1;
+
+ /* Initialize no required char, and count of literals */
+ *reqchar = prevreqchar = -1;
+ *countlits = 0;
+
+ /* Switch on next character until the end of the branch */
+ for (; ptr <= cd->end; ptr++)
+ {
+ BOOL negate_class;
+ int class_charcount;
+ int class_lastchar;
+ int newoptions;
+ int skipbytes;
+ int subreqchar;
+
+ c = *ptr;
+ if ((options & PCRE_EXTENDED) != 0)
+ {
+ if ((cd->ctypes[c] & ctype_space) != 0)
+ continue;
+ if (c == '#')
+ {
+ /* The space before the ; is to avoid a warning on a silly compiler
+ on the Macintosh. */
+ while (ptr < cd->end && (c = *(++ptr)) != 0 && c != '\n');
+ continue;
+ }
+ }
+
+ switch (c)
+ {
+ /* The branch terminates at end of string, |, or ). */
+
+ case '|':
+ case ')':
+ goto SUCCEEDED;
+
+ /* Handle single-character metacharacters */
+
+ case '^':
+ previous = NULL;
+ *code++ = OP_CIRC;
+ break;
+
+ case '$':
+ previous = NULL;
+ *code++ = OP_DOLL;
+ break;
+
+ case '.':
+ previous = code;
+ *code++ = OP_ANY;
+ break;
+
+ /* Character classes. These always build a 32-byte bitmap of the permitted
+ characters, except in the special case where there is only one character.
+ For negated classes, we build the map as usual, then invert it at the end.
+ */
+
+ case '[':
+ previous = code;
+ *code++ = OP_CLASS;
+
+ /* If the first character is '^', set the negation flag and skip it. */
+
+ if ((c = *(++ptr)) == '^')
+ {
+ negate_class = TRUE;
+ c = *(++ptr);
+ }
+ else
+ negate_class = FALSE;
+
+ /* Keep a count of chars so that we can optimize the case of just a single
+ character. */
+
+ class_charcount = 0;
+ class_lastchar = -1;
+
+ /* Initialize the 32-char bit map to all zeros. We have to build the
+ map in a temporary bit of store, in case the class contains only 1
+ character, because in that case the compiled code doesn't use the
+ bit map. */
+
+ memset (class, 0, 32 * sizeof (uschar));
+
+ /* Process characters until ] is reached. By writing this as a "do" it
+ means that an initial ] is taken as a data character. We also have
+ to take care of this in the `if' below: it is an error if we reach the
+ last character and we have not added a data character yet, because a
+ closing bracket will not be considered as a terminator. */
+
+ do
+ {
+ if (ptr > cd->end
+ || (ptr == cd->end && *ptr != ']')
+ || (ptr == cd->end && class_charcount == 0))
+ {
+ *errorptr = pcre_estrings[6];
+ goto FAILED;
+ }
+
+ /* Handle POSIX class names. Perl allows a negation extension of the
+ form [:^name]. A square bracket that doesn't match the syntax is
+ treated as a literal. We also recognize the POSIX constructions
+ [.ch.] and [=ch=] ("collating elements") and fault them, as Perl
+ 5.6 does. */
+
+ if (c == '[' &&
+ (ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
+ check_posix_syntax (ptr, &tempptr, cd))
+ {
+ BOOL local_negate = FALSE;
+ int posix_class, i;
+ register const uschar *cbits = cd->cbits;
+
+ if (ptr[1] != ':')
+ {
+ *errorptr = pcre_estrings[31];
+ goto FAILED;
+ }
+
+ ptr += 2;
+ if (*ptr == '^')
+ {
+ local_negate = TRUE;
+ ptr++;
+ }
+
+ posix_class = check_posix_name (ptr, tempptr - ptr);
+ if (posix_class < 0)
+ {
+ *errorptr = pcre_estrings[30];
+ goto FAILED;
+ }
+
+ /* If matching is caseless, upper and lower are converted to
+ alpha. This relies on the fact that the class table starts with
+ alpha, lower, upper as the first 3 entries. */
+
+ if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
+ posix_class = 0;
+
+ /* Or into the map we are building up to 3 of the static class
+ tables, or their negations. */
+
+ posix_class *= 3;
+ for (i = 0; i < 3; i++)
+ {
+ int taboffset = posix_class_maps[posix_class + i];
+ if (taboffset < 0)
+ break;
+ if (local_negate)
+ for (c = 0; c < 32; c++)
+ class[c] |= ~cbits[c + taboffset];
+ else
+ for (c = 0; c < 32; c++)
+ class[c] |= cbits[c + taboffset];
+ }
+
+ ptr = tempptr + 1;
+ class_charcount = 10; /* Set > 1; assumes more than 1 per class */
+ continue;
+ }
+
+ /* Backslash may introduce a single character, or it may introduce one
+ of the specials, which just set a flag. Escaped items are checked for
+ validity in the pre-compiling pass. The sequence \b is a special case.
+ Inside a class (and only there) it is treated as backspace. Elsewhere
+ it marks a word boundary. Other escapes have preset maps ready to
+ or into the one we are building. We assume they have more than one
+ character in them, so set class_count bigger than one. */
+
+ if (c == '\\')
+ {
+ c = check_escape (&ptr, errorptr, *brackets, options, TRUE, cd);
+ if (-c == ESC_b)
+ c = '\b';
+ else if (c < 0)
+ {
+ register const uschar *cbits = cd->cbits;
+ class_charcount = 10;
+ switch (-c)
+ {
+ case ESC_d:
+ for (c = 0; c < 32; c++)
+ class[c] |= cbits[c + cbit_digit];
+ continue;
+
+ case ESC_D:
+ for (c = 0; c < 32; c++)
+ class[c] |= ~cbits[c + cbit_digit];
+ continue;
+
+ case ESC_w:
+ for (c = 0; c < 32; c++)
+ class[c] |= cbits[c + cbit_word];
+ continue;
+
+ case ESC_W:
+ for (c = 0; c < 32; c++)
+ class[c] |= ~cbits[c + cbit_word];
+ continue;
+
+ case ESC_s:
+ for (c = 0; c < 32; c++)
+ class[c] |= cbits[c + cbit_space];
+ continue;
+
+ case ESC_S:
+ for (c = 0; c < 32; c++)
+ class[c] |= ~cbits[c + cbit_space];
+ continue;
+
+ default:
+ *errorptr = pcre_estrings[7];
+ goto FAILED;
+ }
+ }
+ }
+
+ /* A single character may be followed by '-' to form a range. However,
+ Perl and Posix do not permit ']' to be the end of the range. An hyphen
+ here is treated as a literal. */
+
+ if (ptr[1] == '-' && ptr[2] != ']')
+ {
+ int d;
+ ptr += 2;
+ if (ptr > cd->end)
+ {
+ *errorptr = pcre_estrings[6];
+ goto FAILED;
+ }
+
+ d = *ptr;
+
+ /* The second part of a range can be a single-character escape, but
+ not any of the other escapes. Perl 5.6 treats a hyphen as a literal
+ in such circumstances. */
+
+ if (d == '\\')
+ {
+ const uschar *oldptr = ptr;
+ d = check_escape (&ptr, errorptr, *brackets, options, TRUE, cd);
+
+ /* \b is backslash; any other special means the '-' was literal */
+
+ if (d < 0)
+ {
+ if (d == -ESC_b)
+ d = '\b';
+ else
+ {
+ ptr = oldptr - 2;
+ goto SINGLE_CHARACTER; /* A few lines below */
+ }
+ }
+ }
+
+ if (d < c)
+ {
+ *errorptr = pcre_estrings[8];
+ goto FAILED;
+ }
+
+ for (; c <= d; c++)
+ {
+ class[c / 8] |= (1 << (c & 7));
+ if ((options & PCRE_CASELESS) != 0)
+ {
+ int uc = cd->fcc[c]; /* flip case */
+ class[uc / 8] |= (1 << (uc & 7));
+ }
+ class_charcount++; /* in case a one-char range */
+ class_lastchar = c;
+ }
+ continue; /* Go get the next char in the class */
+ }
+
+ /* Handle a lone single character - we can get here for a normal
+ non-escape char, or after \ that introduces a single character. */
+
+ SINGLE_CHARACTER:
+
+ class[c / 8] |= (1 << (c & 7));
+ if ((options & PCRE_CASELESS) != 0)
+ {
+ c = cd->fcc[c]; /* flip case */
+ class[c / 8] |= (1 << (c & 7));
+ }
+ class_charcount++;
+ class_lastchar = c;
+ }
+
+ /* Loop until ']' reached; the check for end of string happens inside the
+ loop. This "while" is the end of the "do" above. */
+
+ while ((c = *(++ptr)) != ']');
+
+ /* If class_charcount is 1 and class_lastchar is not negative, we saw
+ precisely one character. This doesn't need the whole 32-byte bit map.
+ We turn it into a 1-character OP_CHAR if it's positive, or OP_NOT if
+ it's negative. */
+
+ if (class_charcount == 1 && class_lastchar >= 0)
+ {
+ if (negate_class)
+ {
+ code[-1] = OP_NOT;
+ }
+ else
+ {
+ code[-1] = OP_CHARS;
+ *code++ = 1;
+ }
+ *code++ = class_lastchar;
+ }
+
+ /* Otherwise, negate the 32-byte map if necessary, and copy it into
+ the code vector. */
+
+ else
+ {
+ if (negate_class)
+ for (c = 0; c < 32; c++)
+ code[c] = ~class[c];
+ else
+ memcpy (code, class, 32);
+ code += 32;
+ }
+ break;
+
+ /* Various kinds of repeat */
+
+ case '{':
+ if (!is_counted_repeat (ptr + 1, cd))
+ goto NORMAL_CHAR;
+ repeat_min = repeat_max = 1;
+ ptr = read_repeat_counts (ptr + 1, &repeat_min, &repeat_max, errorptr, cd);
+ if (*errorptr != NULL)
+ goto FAILED;
+ goto REPEAT;
+
+ case '*':
+ repeat_min = 0;
+ repeat_max = -1;
+ goto REPEAT;
+
+ case '+':
+ repeat_min = 1;
+ repeat_max = -1;
+ goto REPEAT;
+
+ case '?':
+ repeat_min = 0;
+ repeat_max = 1;
+
+ REPEAT:
+ if (previous == NULL)
+ {
+ *errorptr = pcre_estrings[9];
+ goto FAILED;
+ }
+
+ /* If the next character is '?' this is a minimizing repeat, by default,
+ but if PCRE_UNGREEDY is set, it works the other way round. Advance to the
+ next character. */
+
+ if (ptr < cd->end && ptr[1] == '?')
+ {
+ repeat_type = greedy_non_default;
+ ptr++;
+ }
+ else
+ repeat_type = greedy_default;
+
+ /* If previous was a string of characters, chop off the last one and use it
+ as the subject of the repeat. If there was only one character, we can
+ abolish the previous item altogether. A repeat with a zero minimum wipes
+ out any reqchar setting, backing up to the previous value. We must also
+ adjust the countlits value. */
+
+ if (*previous == OP_CHARS)
+ {
+ int len = previous[1];
+
+ if (repeat_min == 0)
+ *reqchar = prevreqchar;
+ *countlits += repeat_min - 1;
+
+ if (len == 1)
+ {
+ c = previous[2];
+ code = previous;
+ }
+ else
+ {
+ c = previous[len + 1];
+ previous[1]--;
+ code--;
+ }
+ op_type = 0; /* Use single-char op codes */
+ goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */
+ }
+
+ /* If previous was a single negated character ([^a] or similar), we use
+ one of the special opcodes, replacing it. The code is shared with single-
+ character repeats by adding a suitable offset into repeat_type. */
+
+ else if ((int) *previous == OP_NOT)
+ {
+ op_type = OP_NOT_MAXSTAR - OP_MAXSTAR; /* Use "not" opcodes */
+ c = previous[1];
+ code = previous;
+ goto OUTPUT_SINGLE_REPEAT;
+ }
+
+ /* If previous was a character type match (\d or similar), abolish it and
+ create a suitable repeat item. The code is shared with single-character
+ repeats by adding a suitable offset into repeat_type. */
+
+ else if (*previous == OP_TYPE || *previous == OP_TYPENOT ||
+ *previous == OP_ANY)
+ {
+ if (*previous == OP_ANY)
+ {
+ c = 0;
+ *previous = OP_TYPENOT;
+ }
+ else
+ c = previous[1];
+
+ op_type = *previous - OP_CHARS;
+ code = previous;
+
+ OUTPUT_SINGLE_REPEAT:
+
+ /* If the maximum is zero then the minimum must also be zero; Perl allows
+ this case, so we do too - by simply omitting the item altogether. */
+
+ if (repeat_max == 0)
+ goto END_REPEAT;
+
+ /* Combine the op_type with the repeat_type */
+
+ repeat_type += op_type;
+
+ /* A minimum of zero is handled either as the special case * or ?, or as
+ an UPTO, with the maximum given. */
+
+ if (repeat_min == 0)
+ {
+ if (repeat_max == -1)
+ *code++ = OP_MAXSTAR + repeat_type;
+ else if (repeat_max == 1)
+ *code++ = OP_MAXQUERY + repeat_type;
+ else
+ {
+ *code++ = OP_MAXUPTO + repeat_type;
+ *code++ = repeat_max >> 8;
+ *code++ = (repeat_max & 255);
+ }
+ }
+
+ /* The case {1,} is handled as the special case + */
+
+ else if (repeat_min == 1 && repeat_max == -1)
+ *code++ = OP_MAXPLUS + repeat_type;
+
+ /* The case {n,n} is just an EXACT, while the general case {n,m} is
+ handled as an EXACT followed by an UPTO. An EXACT of 1 is optimized. */
+
+ else
+ {
+ if (repeat_min != 1)
+ {
+ *code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */
+ *code++ = repeat_min >> 8;
+ *code++ = (repeat_min & 255);
+ }
+
+ /* If the mininum is 1 and the previous item was a character string,
+ we either have to put back the item that got cancelled if the string
+ length was 1, or add the character back onto the end of a longer
+ string. For a character type nothing need be done; it will just get
+ put back naturally. Note that the final character is always going to
+ get added below. */
+
+ else if (*previous == OP_CHARS)
+ {
+ if (code == previous)
+ code += 2;
+ else
+ previous[1]++;
+ }
+
+ /* For a negated character or class we also have to put
+ back the item that got cancelled. */
+
+ else if (*previous == OP_NOT || *previous == OP_TYPE ||
+ *previous == OP_TYPENOT)
+ code++;
+
+ /* If the maximum is unlimited, insert an OP_MAXSTAR. */
+
+ if (repeat_max < 0)
+ {
+ *code++ = c;
+ *code++ = OP_MAXSTAR + repeat_type;
+ }
+
+ /* Else insert an UPTO if the max is greater than the min. */
+
+ else if (repeat_max != repeat_min)
+ {
+ *code++ = c;
+ repeat_max -= repeat_min;
+ *code++ = OP_MAXUPTO + repeat_type;
+ *code++ = repeat_max >> 8;
+ *code++ = (repeat_max & 255);
+ }
+ }
+
+ /* The character or character type itself comes last in all cases. */
+
+ *code++ = c;
+ }
+
+ /* If previous was a character class or a back reference, we put the repeat
+ stuff after it, but just skip the item if the repeat was {0,0}. */
+
+ else if (*previous == OP_CLASS || *previous == OP_REF)
+ {
+ if (repeat_max == 0)
+ {
+ code = previous;
+ goto END_REPEAT;
+ }
+
+ if (*previous == OP_REF)
+ repeat_type += OP_REF - OP_CLASS;
+
+ if (repeat_min == 0 && repeat_max == -1)
+ *previous = OP_CL_MAXSTAR + repeat_type;
+ else if (repeat_min == 1 && repeat_max == -1)
+ *previous = OP_CL_MAXPLUS + repeat_type;
+ else if (repeat_min == 0 && repeat_max == 1)
+ *previous = OP_CL_MAXQUERY + repeat_type;
+ else
+ {
+ *previous = OP_CL_MAXRANGE + repeat_type;
+ *code++ = repeat_min >> 8;
+ *code++ = repeat_min & 255;
+ if (repeat_max == -1)
+ repeat_max = 0; /* 2-byte encoding for max */
+ *code++ = repeat_max >> 8;
+ *code++ = repeat_max & 255;
+ }
+ }
+
+ /* If previous was a bracket group, we may have to replicate it in certain
+ cases. */
+
+ else if ((int) *previous >= OP_BRA || (int) *previous == OP_ONCE ||
+ (int) *previous == OP_COND)
+ {
+ register int i;
+ int ketoffset = 0;
+ int len = code - previous;
+ uschar *bralink = NULL;
+
+ /* If the maximum repeat count is unlimited, find the end of the bracket
+ by scanning through from the start, and compute the offset back to it
+ from the current code pointer. There may be an OP_OPT setting following
+ the final KET, so we can't find the end just by going back from the code
+ pointer. */
+
+ if (repeat_max == -1)
+ {
+ register uschar *ket = previous;
+ do
+ ket += (ket[1] << 8) + ket[2];
+ while (*ket != OP_KET);
+ ketoffset = code - ket;
+ }
+
+ /* The case of a zero minimum is special because of the need to stick
+ OP_BRAZERO in front of it, and because the group appears once in the
+ data, whereas in other cases it appears the minimum number of times. For
+ this reason, it is simplest to treat this case separately, as otherwise
+ the code gets far too messy. There are several special subcases when the
+ minimum is zero. */
+
+ if (repeat_min == 0)
+ {
+ /* If we set up a required char from the bracket, we must back off
+ to the previous value and reset the countlits value too. */
+
+ if (subcountlits > 0)
+ {
+ *reqchar = prevreqchar;
+ *countlits -= subcountlits;
+ }
+
+ /* If the maximum is also zero, we just omit the group from the output
+ altogether. */
+
+ if (repeat_max == 0)
+ {
+ code = previous;
+ goto END_REPEAT;
+ }
+
+ /* If the maximum is 1 or unlimited, we just have to stick in the
+ BRAZERO and do no more at this point. */
+
+ if (repeat_max <= 1)
+ {
+ memmove (previous + 1, previous, len);
+ code++;
+ *previous++ = OP_BRAZERO + repeat_type;
+ }
+
+ /* If the maximum is greater than 1 and limited, we have to replicate
+ in a nested fashion, sticking OP_BRAZERO before each set of brackets.
+ The first one has to be handled carefully because it's the original
+ copy, which has to be moved up. The remainder can be handled by code
+ that is common with the non-zero minimum case below. We just have to
+ adjust the value or repeat_max, since one less copy is required. */
+
+ else
+ {
+ int offset;
+ memmove (previous + 4, previous, len);
+ code += 4;
+ *previous++ = OP_BRAZERO + repeat_type;
+ *previous++ = OP_BRA;
+
+ /* We chain together the bracket offset fields that have to be
+ filled in later when the ends of the brackets are reached. */
+
+ offset = (bralink == NULL) ? 0 : previous - bralink;
+ bralink = previous;
+ *previous++ = offset >> 8;
+ *previous++ = offset & 255;
+ }
+
+ repeat_max--;
+ }
+
+ /* If the minimum is greater than zero, replicate the group as many
+ times as necessary, and adjust the maximum to the number of subsequent
+ copies that we need. */
+
+ else
+ {
+ for (i = 1; i < repeat_min; i++)
+ {
+ memcpy (code, previous, len);
+ code += len;
+ }
+ if (repeat_max > 0)
+ repeat_max -= repeat_min;
+ }
+
+ /* This code is common to both the zero and non-zero minimum cases. If
+ the maximum is limited, it replicates the group in a nested fashion,
+ remembering the bracket starts on a stack. In the case of a zero minimum,
+ the first one was set up above. In all cases the repeat_max now specifies
+ the number of additional copies needed. */
+
+ if (repeat_max >= 0)
+ {
+ for (i = repeat_max - 1; i >= 0; i--)
+ {
+ *code++ = OP_BRAZERO + repeat_type;
+
+ /* All but the final copy start a new nesting, maintaining the
+ chain of brackets outstanding. */
+
+ if (i != 0)
+ {
+ int offset;
+ *code++ = OP_BRA;
+ offset = (bralink == NULL) ? 0 : code - bralink;
+ bralink = code;
+ *code++ = offset >> 8;
+ *code++ = offset & 255;
+ }
+
+ memcpy (code, previous, len);
+ code += len;
+ }
+
+ /* Now chain through the pending brackets, and fill in their length
+ fields (which are holding the chain links pro tem). */
+
+ while (bralink != NULL)
+ {
+ int oldlinkoffset;
+ int offset = code - bralink + 1;
+ uschar *bra = code - offset;
+ oldlinkoffset = (bra[1] << 8) + bra[2];
+ bralink = (oldlinkoffset == 0) ? NULL : bralink - oldlinkoffset;
+ *code++ = OP_KET;
+ *code++ = bra[1] = offset >> 8;
+ *code++ = bra[2] = (offset & 255);
+ }
+ }
+
+ /* If the maximum is unlimited, set a repeater in the final copy. We
+ can't just offset backwards from the current code point, because we
+ don't know if there's been an options resetting after the ket. The
+ correct offset was computed above. */
+
+ else
+ code[-ketoffset] = OP_KET_MAXSTAR + repeat_type;
+ }
+
+ /* Else there's some kind of shambles */
+
+ else
+ {
+ *errorptr = pcre_estrings[11];
+ goto FAILED;
+ }
+
+ /* In all case we no longer have a previous item. */
+
+ END_REPEAT:
+ previous = NULL;
+ break;
+
+
+ /* Start of nested bracket sub-expression, or comment or lookahead or
+ lookbehind or option setting or condition. First deal with special things
+ that can come after a bracket; all are introduced by ?, and the appearance
+ of any of them means that this is not a referencing group. They were
+ checked for validity in the first pass over the string, so we don't have to
+ check for syntax errors here. */
+
+ case '(':
+ newoptions = options;
+ skipbytes = 0;
+
+ if (ptr == cd->end)
+ {
+ *errorptr = pcre_estrings[22];
+ goto FAILED;
+ }
+
+ if (*(++ptr) == '?')
+ {
+ int set, unset;
+ int *optset;
+
+ if (ptr == cd->end)
+ {
+ *errorptr = pcre_estrings[22];
+ goto FAILED;
+ }
+
+ switch (*(++ptr))
+ {
+ case '#': /* Comment; skip to ket */
+ ptr++;
+ while (ptr <= cd->end && *ptr != ')')
+ ptr++;
+ continue;
+
+ case ':': /* Non-capturing bracket */
+ bravalue = OP_BRA;
+ ptr++;
+ break;
+
+ case '(':
+ bravalue = OP_COND; /* Conditional group */
+ if (ptr < cd->end &&
+ (cd->ctypes[*(++ptr)] & ctype_digit) != 0)
+ {
+ int condref = *ptr - '0';
+ while (ptr < cd->end && *(++ptr) != ')')
+ condref = condref * 10 + *ptr - '0';
+ if (condref == 0)
+ {
+ *errorptr = pcre_estrings[32];
+ goto FAILED;
+ }
+ ptr++;
+ code[3] = OP_CREF;
+ code[4] = condref >> 8;
+ code[5] = condref & 255;
+ skipbytes = 3;
+ }
+ else
+ ptr--;
+ break;
+
+ case '=': /* Positive lookahead */
+ bravalue = OP_ASSERT;
+ ptr++;
+ break;
+
+ case '!': /* Negative lookahead */
+ bravalue = OP_ASSERT_NOT;
+ ptr++;
+ break;
+
+ case '<': /* Lookbehinds */
+ if (ptr < cd->end)
+ ptr++;
+ /* else stay on the < so we have a syntax error */
+
+ switch (*ptr)
+ {
+ case '=': /* Positive lookbehind */
+ bravalue = OP_ASSERTBACK;
+ ptr++;
+ break;
+
+ case '!': /* Negative lookbehind */
+ bravalue = OP_ASSERTBACK_NOT;
+ ptr++;
+ break;
+
+ default: /* Syntax error */
+ *errorptr = pcre_estrings[24];
+ goto FAILED;
+ }
+ break;
+
+ case '>': /* One-time brackets */
+ bravalue = OP_ONCE;
+ ptr++;
+ break;
+
+ case 'R': /* Pattern recursion */
+ *code++ = OP_RECURSE;
+ ptr++;
+ continue;
+
+ default: /* Option setting */
+ set = unset = 0;
+ optset = &set;
+
+ while (ptr <= cd->end && *ptr != ')' && *ptr != ':')
+ {
+ switch (*ptr++)
+ {
+ case '-':
+ optset = &unset;
+ break;
+
+ case 'i':
+ *optset |= PCRE_CASELESS;
+ break;
+ case 'm':
+ *optset |= PCRE_MULTILINE;
+ break;
+ case 's':
+ *optset |= PCRE_DOTALL;
+ break;
+ case 'x':
+ *optset |= PCRE_EXTENDED;
+ break;
+ case 'U':
+ *optset |= PCRE_UNGREEDY;
+ break;
+ case 'X':
+ *optset |= PCRE_EXTRA;
+ break;
+
+ default:
+ *errorptr = pcre_estrings[12];
+ goto FAILED;
+ }
+ }
+
+ /* Set up the changed option bits, but don't change anything yet. */
+
+ newoptions = (options | set) & (~unset);
+
+ /* If the options ended with ')' this is not the start of a nested
+ group with option changes, so the options change at this level. At top
+ level there is nothing else to be done (the options will in fact have
+ been set from the start of compiling as a result of the first pass) but
+ at an inner level we must compile code to change the ims options if
+ necessary, and pass the new setting back so that it can be put at the
+ start of any following branches, and when this group ends, a resetting
+ item can be compiled. */
+
+ if (*ptr == ')')
+ {
+ if ((options & PCRE_INGROUP) != 0 &&
+ (options & PCRE_IMS) != (newoptions & PCRE_IMS))
+ {
+ *code++ = OP_OPT;
+ *code++ = *optchanged = newoptions & PCRE_IMS;
+ }
+ options = newoptions; /* Change options at this level */
+ previous = NULL; /* This item can't be repeated */
+ continue; /* It is complete */
+ }
+
+ /* If the options ended with ':' we are heading into a nested group
+ with possible change of options. Such groups are non-capturing and are
+ not assertions of any kind. All we need to do is skip over the ':';
+ the newoptions value is handled below. */
+
+ bravalue = OP_BRA;
+ ptr++;
+ }
+ }
+
+ /* Else we have a referencing group; adjust the opcode. If the bracket
+ number is greater than EXTRACT_BASIC_MAX, we set the opcode one higher, and
+ arrange for the true number to follow later, in an OP_BRANUMBER item. */
+
+ else
+ {
+ if (++(*brackets) > EXTRACT_BASIC_MAX)
+ {
+ bravalue = OP_BRA + EXTRACT_BASIC_MAX + 1;
+ code[3] = OP_BRANUMBER;
+ code[4] = *brackets >> 8;
+ code[5] = *brackets & 255;
+ skipbytes = 3;
+ }
+ else
+ bravalue = OP_BRA + *brackets;
+ }
+
+ /* Process nested bracketed re. Assertions may not be repeated, but other
+ kinds can be. We copy code into a non-register variable in order to be able
+ to pass its address because some compilers complain otherwise. Pass in a
+ new setting for the ims options if they have changed. */
+
+ previous = (bravalue >= OP_ONCE) ? code : NULL;
+ *code = bravalue;
+ tempcode = code;
+
+ if (!compile_regex (
+ options | PCRE_INGROUP, /* Set for all nested groups */
+ ((options & PCRE_IMS) != (newoptions & PCRE_IMS)) ?
+ newoptions & PCRE_IMS : -1, /* Pass ims options if changed */
+ brackets, /* Capturing bracket count */
+ &tempcode, /* Where to put code (updated) */
+ &ptr, /* Input pointer (updated) */
+ errorptr, /* Where to put an error message */
+ (bravalue == OP_ASSERTBACK ||
+ bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
+ skipbytes, /* Skip over OP_COND/OP_BRANUMBER */
+ &subreqchar, /* For possible last char */
+ &subcountlits, /* For literal count */
+ cd, /* Tables block */
+ compile_branch_perl))
+ goto FAILED;
+
+ /* At the end of compiling, code is still pointing to the start of the
+ group, while tempcode has been updated to point past the end of the group
+ and any option resetting that may follow it. The pattern pointer (ptr)
+ is on the bracket. */
+
+ /* If this is a conditional bracket, check that there are no more than
+ two branches in the group. */
+
+ else if (bravalue == OP_COND)
+ {
+ uschar *tc = code;
+ condcount = 0;
+
+ do
+ {
+ condcount++;
+ tc += (tc[1] << 8) | tc[2];
+ }
+ while (*tc != OP_KET);
+
+ if (condcount > 2)
+ {
+ *errorptr = pcre_estrings[27];
+ goto FAILED;
+ }
+ }
+
+ /* Handle updating of the required character. If the subpattern didn't
+ set one, leave it as it was. Otherwise, update it for normal brackets of
+ all kinds, forward assertions, and conditions with two branches. Don't
+ update the literal count for forward assertions, however. If the bracket
+ is followed by a quantifier with zero repeat, we have to back off. Hence
+ the definition of prevreqchar and subcountlits outside the main loop so
+ that they can be accessed for the back off. */
+
+ if (subreqchar > 0 &&
+ (bravalue >= OP_BRA || bravalue == OP_ONCE || bravalue == OP_ASSERT ||
+ (bravalue == OP_COND && condcount == 2)))
+ {
+ prevreqchar = *reqchar;
+ *reqchar = subreqchar;
+ if (bravalue != OP_ASSERT)
+ *countlits += subcountlits;
+ }
+
+ /* Now update the main code pointer to the end of the group. */
+
+ code = tempcode;
+
+ /* Error if hit end of pattern */
+
+ if (ptr > cd->end || *ptr != ')')
+ {
+ *errorptr = pcre_estrings[22];
+ goto FAILED;
+ }
+ break;
+
+ /* Check \ for being a real metacharacter; if not, fall through and handle
+ it as a data character at the start of a string. Escape items are checked
+ for validity in the pre-compiling pass. */
+
+ case '\\':
+ tempptr = ptr;
+ c = check_escape (&ptr, errorptr, *brackets, options, FALSE, cd);
+
+ /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values
+ are arranged to be the negation of the corresponding OP_values. For the
+ back references, the values are ESC_REF plus the reference number. Only
+ back references and those types that consume a character may be repeated. */
+
+ if (c < 0)
+ {
+ c = -c;
+ if (c >= ESC_REF)
+ {
+ int number = c - ESC_REF;
+ previous = code;
+ *code++ = OP_REF;
+ *code++ = number >> 8;
+ *code++ = number & 255;
+ }
+ else if (c >= ESC_FIRST_CONSUME && c <= ESC_LAST_CONSUME)
+ {
+ c -= ESC_FIRST_CONSUME;
+ previous = code;
+ *code++ = (c & 1) ? OP_TYPE : OP_TYPENOT;
+ *code++ = (c >> 1) + 1;
+ }
+ else
+ {
+ previous = NULL;
+ *code++ = c;
+ }
+ continue;
+ }
+
+ /* Data character: reset and fall through */
+
+ ptr = tempptr;
+ c = '\\';
+
+ /* Handle a run of data characters until a metacharacter is encountered.
+ The first character is guaranteed not to be whitespace or # when the
+ extended flag is set. */
+
+ NORMAL_CHAR:
+ default:
+ previous = code;
+ *code = OP_CHARS;
+ code += 2;
+ length = 0;
+
+ do
+ {
+ if ((options & PCRE_EXTENDED) != 0)
+ {
+ if ((cd->ctypes[c] & ctype_space) != 0)
+ continue;
+ if (c == '#')
+ {
+ /* The space before the ; is to avoid a warning on a silly compiler
+ on the Macintosh. */
+ while ((c = *(++ptr)) != 0 && c != '\n');
+ if (c == 0)
+ break;
+ continue;
+ }
+ }
+
+ /* Backslash may introduce a data char or a metacharacter. Escaped items
+ are checked for validity in the pre-compiling pass. Stop the string
+ before a metaitem. */
+
+ if (c == '\\')
+ {
+ tempptr = ptr;
+ c = check_escape (&ptr, errorptr, *brackets, options, FALSE, cd);
+ if (c < 0)
+ {
+ ptr = tempptr - 1;
+ c = '\\';
+ break;
+ }
+ }
+
+ /* Ordinary character or single-char escape */
+ *code++ = c;
+ c = 0;
+ length++;
+ }
+
+ /* This "while" is the end of the "do" above. */
+
+ while (length < MAXLIT && ptr < cd->end
+ && (cd->ctypes[c = *(++ptr)] & ctype_meta) == 0);
+
+ /* Update the last character and the count of literals */
+
+ prevreqchar = (length > 1) ? code[-2] : *reqchar;
+ *reqchar = code[-1];
+ *countlits += length;
+
+ /* Compute the length and set it in the data vector, and advance to
+ the next state. */
+
+ previous[1] = length;
+ if (cd->ctypes[c] & ctype_meta)
+ ptr--;
+ break;
+ }
+ } /* end of big loop */
+
+SUCCEEDED:
+ *codeptr = code;
+ *ptrptr = ptr;
+ return TRUE;
+
+ /* Control never reaches here by falling through, only by a goto for all the
+ error states. Pass back the position in the pattern so that it can be displayed
+ to the user for diagnosing the error. */
+FAILED:
+ *ptrptr = ptr;
+ return FALSE;
+}
+
+
+
+/*************************************************
+* Compile a Regular Expression *
+*************************************************/
+
+/* This function takes a string and returns a pointer to a block of store
+ holding a compiled version of the expression.
+
+ Arguments:
+ pattern the regular expression
+ options various option bits
+ errorptr pointer to pointer to error text
+ erroroffset ptr offset in pattern where error was detected
+ tables pointer to character tables or NULL
+
+ Returns: pointer to compiled data block, or NULL on error,
+ with errorptr and erroroffset set
+ */
+
+pcre *
+pcre_compile (pattern, options, errorptr, erroroffset, tables)
+ const char *pattern;
+ int options;
+ const char **errorptr;
+ int *erroroffset;
+ const unsigned char *tables;
+{
+ return pcre_compile_nuls (pattern, (int) strlen (pattern), options,
+ errorptr, erroroffset, tables);
+}
+
+pcre *
+pcre_compile_nuls (pattern, patlen, options,
+ errorptr, erroroffset, tables)
+ const char *pattern;
+ int patlen;
+ int options;
+ const char **errorptr;
+ int *erroroffset;
+ const unsigned char *tables;
+{
+ pcre *re;
+ int length = 3; /* For initial BRA plus length */
+ int runlength;
+ int c, reqchar, countlits;
+ int bracount = 0;
+ int top_backref = 0;
+ int branch_extra = 0;
+ int branch_newextra;
+ unsigned int brastackptr = 0;
+ size_t size;
+ uschar *code;
+ const uschar *ptr;
+ compile_data compile_block;
+ int brastack[BRASTACK_SIZE];
+ uschar bralenstack[BRASTACK_SIZE];
+ static const unsigned char *def_tables;
+
+#ifdef DEBUG
+ uschar *code_base, *code_end;
+#endif
+
+ /* We can't pass back an error message if errorptr is NULL; I guess the best we
+ can do is just return NULL. */
+ if (errorptr == NULL)
+ return NULL;
+ *errorptr = NULL;
+
+ /* However, we can give a message for this error */
+ if (erroroffset == NULL)
+ {
+ *errorptr = pcre_estrings[16];
+ return NULL;
+ }
+ *erroroffset = 0;
+
+ if ((options & ~PUBLIC_OPTIONS) != 0)
+ {
+ *errorptr = pcre_estrings[17];
+ return NULL;
+ }
+
+ /* Set up pointers to the individual character tables */
+ if (!tables)
+ {
+ if (!def_tables)
+ def_tables = pcre_maketables ();
+ tables = def_tables;
+ }
+ compile_block.lcc = tables + lcc_offset;
+ compile_block.fcc = tables + fcc_offset;
+ compile_block.cbits = tables + cbits_offset;
+ compile_block.ctypes = tables + ctypes_offset;
+ compile_block.end = pattern + patlen - 1;
+
+ /* Reflect pattern for debugging output */
+ DPRINTF (("------------------------------------------------------------------\n"));
+ DFWRITE ((pattern, 1, patlen, stdout));
+ DPRINTF (("\n"));
+
+ /* The first thing to do is to make a pass over the pattern to compute the
+ amount of store required to hold the compiled code. This does not have to be
+ perfect as long as errors are overestimates. At the same time we can detect any
+ internal flag settings. Make an attempt to correct for any counted white space
+ if an "extended" flag setting appears late in the pattern. We can't be so
+ clever for #-comments. */
+ for (ptr = (const uschar *) pattern; ptr <= compile_block.end; ptr++)
+ {
+ int min, max;
+ int class_charcount;
+ int bracket_length;
+
+ c = *ptr;
+ if ((options & PCRE_EXTENDED) != 0)
+ {
+ if ((compile_block.ctypes[c] & ctype_space) != 0)
+ continue;
+ if (c == '#')
+ {
+ /* The space before the ; is to avoid a warning on a silly compiler
+ on the Macintosh. */
+ while ((c = *(++ptr)) != 0 && c != '\n');
+ continue;
+ }
+ }
+
+ switch (c)
+ {
+ /* A backslashed item may be an escaped "normal" character or a
+ character type. For a "normal" character, put the pointers and
+ character back so that tests for whitespace etc. in the input
+ are done correctly. */
+
+ case '\\':
+ {
+ const uschar *save_ptr = ptr;
+ if (ptr == compile_block.end)
+ *errorptr = pcre_estrings[1];
+ else
+ c = check_escape (&ptr, errorptr, bracount, options, FALSE,
+ &compile_block);
+
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if (c >= 0)
+ {
+ ptr = save_ptr;
+ c = '\\';
+ goto NORMAL_CHAR;
+ }
+ }
+
+ /* A back reference needs an additional 2 bytes, plus either 0 or 4
+ bytes for a repeat. We also need to keep the value of the highest
+ back reference. */
+
+ if (c <= -ESC_REF)
+ {
+ int refnum = -c - ESC_REF;
+ if (refnum > top_backref)
+ top_backref = refnum;
+ length += 3; /* For single back reference */
+ if (ptr < compile_block.end && ptr[1] == '{' &&
+ is_counted_repeat (ptr + 2, &compile_block))
+ {
+ min = max = 1;
+ ptr = read_repeat_counts (ptr + 2, &min, &max, errorptr, &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if ((min == 0 && (max == 1 || max == -1)) ||
+ (min == 1 && max == -1))
+ ;
+ else
+ length += 4;
+ }
+ }
+ else if (c <= 0)
+ length += 2;
+ else
+ length++;
+ continue;
+
+ case '.':
+ if (ptr != compile_block.end && *(ptr + 1) == '{')
+ length++;
+
+ /* fall through */
+
+ case '^':
+ case '$':
+ case '*': /* These repeats won't be after brackets; */
+ case '+': /* those are handled separately */
+ case '?':
+ length++;
+ continue;
+
+ /* This covers the cases of repeats after a single char, metachar, class,
+ or back reference. */
+
+ case '{':
+ if (!is_counted_repeat (ptr + 1, &compile_block))
+ goto NORMAL_CHAR;
+ min = max = 1;
+ ptr = read_repeat_counts (ptr + 1, &min, &max, errorptr, &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if ((min == 0 && (max == 1 || max == -1)) ||
+ (min == 1 && max == -1))
+ length++;
+ else
+ {
+ length--; /* Uncount the original char or metachar */
+ if (min == 1)
+ length++;
+ else if (min > 0)
+ length += 4;
+ if (max > 0)
+ length += 4;
+ else
+ length += 2;
+ }
+ if (ptr < compile_block.end && ptr[1] == '?')
+ ptr++;
+ continue;
+
+ /* An alternation contains an offset to the next branch or ket. If any ims
+ options changed in the previous branch(es), and/or if we are in a
+ lookbehind assertion, extra space will be needed at the start of the
+ branch. This is handled by branch_extra. */
+
+ case '|':
+ length += 3 + branch_extra;
+ continue;
+
+ /* A character class uses 33 characters. Don't worry about character types
+ that aren't allowed in classes - they'll get picked up during the compile.
+ A character class that contains only one character uses 2 or 3 bytes,
+ depending on whether it is negated or not. Notice this where we can. */
+
+ case '[':
+ class_charcount = 0;
+ if (ptr < compile_block.end && *(++ptr) == '^')
+ ptr++;
+
+ if (ptr <= compile_block.end)
+ do
+ {
+ if (*ptr == '\\')
+ {
+ int ch;
+ if (ptr == compile_block.end)
+ *errorptr = pcre_estrings[1];
+ else
+ ch = check_escape (&ptr, errorptr, bracount, options, TRUE,
+ &compile_block);
+
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if (-ch == ESC_b)
+ class_charcount++;
+ else
+ class_charcount = 10;
+ }
+ else
+ class_charcount++;
+ ptr++;
+ }
+ while (ptr <= compile_block.end && *ptr != ']');
+
+ /* Repeats for negated single chars are handled by the general code */
+
+ if (class_charcount == 1)
+ length += 3;
+ else
+ {
+ length += 33;
+
+ /* A repeat needs either 0 or 4 bytes. */
+
+ if (ptr < compile_block.end && ptr[1] == '{' && is_counted_repeat (ptr + 2, &compile_block))
+ {
+ min = max = 1;
+ ptr = read_repeat_counts (ptr + 2, &min, &max, errorptr, &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if ((min == 0 && (max == 1 || max == -1)) ||
+ (min == 1 && max == -1))
+ ;
+ else
+ length += 4;
+ if (ptr < compile_block.end && ptr[1] == '?')
+ ptr++;
+ }
+ }
+ continue;
+
+ /* Brackets may be genuine groups or special things */
+
+ case '(':
+ branch_newextra = 0;
+ bracket_length = 3;
+
+ /* Handle special forms of bracket, which all start (? */
+
+ if (ptr < compile_block.end && ptr[1] == '?')
+ {
+ int set, unset;
+ int *optset;
+
+ switch (c = ptr[2])
+ {
+ /* Skip over comments entirely */
+ case '#':
+ ptr += 3;
+ while (ptr < compile_block.end && *ptr != ')')
+ ptr++;
+ if (*ptr != ')')
+ {
+ *errorptr = pcre_estrings[18];
+ goto PCRE_ERROR_RETURN;
+ }
+ continue;
+
+ /* Non-referencing groups and lookaheads just move the pointer on, and
+ then behave like a non-special bracket, except that they don't increment
+ the count of capturing brackets. Ditto for the "once only" bracket,
+ which is in Perl from version 5.005. */
+
+ case ':':
+ case '=':
+ case '!':
+ case '>':
+ ptr += 2;
+ break;
+
+ /* A recursive call to the regex is an extension, to provide the
+ facility which can be obtained by $(?p{perl-code}) in Perl 5.6. */
+
+ case 'R':
+ if (ptr[3] != ')')
+ {
+ *errorptr = pcre_estrings[29];
+ goto PCRE_ERROR_RETURN;
+ }
+ ptr += 3;
+ length += 1;
+ break;
+
+ /* Lookbehinds are in Perl from version 5.005 */
+
+ case '<':
+ if (ptr[3] == '=' || ptr[3] == '!')
+ {
+ ptr += 3;
+ branch_newextra = 3;
+ length += 3; /* For the first branch */
+ break;
+ }
+ *errorptr = pcre_estrings[24];
+ goto PCRE_ERROR_RETURN;
+
+ /* Conditionals are in Perl from version 5.005. The bracket must either
+ be followed by a number (for bracket reference) or by an assertion
+ group. */
+
+ case '(':
+ if ((compile_block.ctypes[ptr[3]] & ctype_digit) != 0)
+ {
+ ptr += 4;
+ length += 3;
+ while ((compile_block.ctypes[*ptr] & ctype_digit) != 0)
+ ptr++;
+ if (*ptr != ')')
+ {
+ *errorptr = pcre_estrings[26];
+ goto PCRE_ERROR_RETURN;
+ }
+ }
+ else
+ /* An assertion must follow */
+ {
+ ptr++; /* Can treat like ':' as far as spacing is concerned */
+ if (ptr[2] != '?' ||
+ (ptr[3] != '=' && ptr[3] != '!' && ptr[3] != '<'))
+ {
+ ptr += 2; /* To get right offset in message */
+ *errorptr = pcre_estrings[28];
+ goto PCRE_ERROR_RETURN;
+ }
+ }
+ break;
+
+ /* Else loop checking valid options until ) is met. Anything else is an
+ error. If we are without any brackets, i.e. at top level, the settings
+ act as if specified in the options, so massage the options immediately.
+ This is for backward compatibility with Perl 5.004. */
+
+ default:
+ set = unset = 0;
+ optset = &set;
+ ptr += 2;
+
+ for (;; ptr++)
+ {
+ c = *ptr;
+ switch (c)
+ {
+ case 'i':
+ *optset |= PCRE_CASELESS;
+ continue;
+
+ case 'm':
+ *optset |= PCRE_MULTILINE;
+ continue;
+
+ case 's':
+ *optset |= PCRE_DOTALL;
+ continue;
+
+ case 'x':
+ *optset |= PCRE_EXTENDED;
+ continue;
+
+ case 'X':
+ *optset |= PCRE_EXTRA;
+ continue;
+
+ case 'U':
+ *optset |= PCRE_UNGREEDY;
+ continue;
+
+ case '-':
+ optset = &unset;
+ continue;
+
+ /* A termination by ')' indicates an options-setting-only item;
+ this is global at top level; otherwise nothing is done here and
+ it is handled during the compiling process on a per-bracket-group
+ basis. */
+
+ case ')':
+ if (brastackptr == 0)
+ {
+ options = (options | set) & (~unset);
+ set = unset = 0; /* To save length */
+ }
+ /* Fall through */
+
+ /* A termination by ':' indicates the start of a nested group with
+ the given options set. This is again handled at compile time, but
+ we must allow for compiled space if any of the ims options are
+ set. We also have to allow for resetting space at the end of
+ the group, which is why 4 is added to the length and not just 2.
+ If there are several changes of options within the same group, this
+ will lead to an over-estimate on the length, but this shouldn't
+ matter very much. We also have to allow for resetting options at
+ the start of any alternations, which we do by setting
+ branch_newextra to 2. Finally, we record whether the case-dependent
+ flag ever changes within the regex. This is used by the "required
+ character" code. */
+
+ case ':':
+ if (((set | unset) & PCRE_IMS) != 0)
+ {
+ length += 4;
+ branch_newextra = 2;
+ if (((set | unset) & PCRE_CASELESS) != 0)
+ options |= PCRE_ICHANGED;
+ }
+ goto END_OPTIONS;
+
+ /* Unrecognized option character */
+
+ default:
+ *errorptr = pcre_estrings[12];
+ goto PCRE_ERROR_RETURN;
+ }
+ }
+
+ /* If we hit a closing bracket, that's it - this is a freestanding
+ option-setting. We need to ensure that branch_extra is updated if
+ necessary. The only values branch_newextra can have here are 0 or 2.
+ If the value is 2, then branch_extra must either be 2 or 5, depending
+ on whether this is a lookbehind group or not. */
+
+ END_OPTIONS:
+ if (c == ')')
+ {
+ if (branch_newextra == 2 && (branch_extra == 0 || branch_extra == 3))
+ branch_extra += branch_newextra;
+ continue;
+ }
+
+ /* If options were terminated by ':' control comes here. Fall through
+ to handle the group below. */
+ }
+ }
+
+ /* Capturing brackets must be counted so we can process escapes in a
+ Perlish way. If the number exceeds EXTRACT_BASIC_MAX we are going to
+ need an additional 3 bytes of store per capturing bracket. */
+
+ else
+ {
+ bracount++;
+ if (bracount > EXTRACT_BASIC_MAX)
+ bracket_length += 3;
+ }
+
+ /* Save length for computing whole length at end if there's a repeat that
+ requires duplication of the group. Also save the current value of
+ branch_extra, and start the new group with the new value. If non-zero, this
+ will either be 2 for a (?imsx: group, or 3 for a lookbehind assertion. */
+
+ if (brastackptr >= sizeof (brastack) / sizeof (int))
+ {
+ *errorptr = pcre_estrings[19];
+ goto PCRE_ERROR_RETURN;
+ }
+
+ bralenstack[brastackptr] = branch_extra;
+ branch_extra = branch_newextra;
+
+ brastack[brastackptr++] = length;
+ length += bracket_length;
+ continue;
+
+ /* Handle ket. Look for subsequent max/min; for certain sets of values we
+ have to replicate this bracket up to that many times. If brastackptr is
+ 0 this is an unmatched bracket which will generate an error, but take care
+ not to try to access brastack[-1] when computing the length and restoring
+ the branch_extra value. */
+
+ case ')':
+ length += 3;
+ {
+ int minval = 1;
+ int maxval = 1;
+ int duplength;
+
+ if (brastackptr > 0)
+ {
+ duplength = length - brastack[--brastackptr];
+ branch_extra = bralenstack[brastackptr];
+ }
+ else
+ duplength = 0;
+
+ /* Leave ptr at the final char; for read_repeat_counts this happens
+ automatically; for the others we need an increment. */
+
+ if (ptr == compile_block.end)
+ {
+ }
+ else if ((c = ptr[1]) == '{' &&
+ is_counted_repeat (ptr + 2, &compile_block))
+ {
+ minval = maxval = 1;
+ ptr = read_repeat_counts (ptr + 2, &minval, &maxval, errorptr,
+ &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ }
+ else if (c == '*')
+ {
+ minval = 0;
+ maxval = -1;
+ ptr++;
+ }
+ else if (c == '+')
+ {
+ maxval = -1;
+ ptr++;
+ }
+ else if (c == '?')
+ {
+ minval = 0;
+ ptr++;
+ }
+
+ /* If the minimum is zero, we have to allow for an OP_BRAZERO before the
+ group, and if the maximum is greater than zero, we have to replicate
+ maxval-1 times; each replication acquires an OP_BRAZERO plus a nesting
+ bracket set - hence the 7. */
+
+ if (minval == 0)
+ {
+ length++;
+ if (maxval > 0)
+ length += (maxval - 1) * (duplength + 7);
+ }
+
+ /* When the minimum is greater than zero, 1 we have to replicate up to
+ minval-1 times, with no additions required in the copies. Then, if
+ there is a limited maximum we have to replicate up to maxval-1 times
+ allowing for a BRAZERO item before each optional copy and nesting
+ brackets for all but one of the optional copies. */
+
+ else
+ {
+ length += (minval - 1) * duplength;
+ if (maxval > minval) /* Need this test as maxval=-1 means no limit */
+ length += (maxval - minval) * (duplength + 7) - 6;
+ }
+ }
+ continue;
+
+ /* Non-special character. For a run of such characters the length required
+ is the number of characters + 2, except that the maximum run length is 255.
+ We won't get a skipped space or a non-data escape or the start of a #
+ comment as the first character, so the length can't be zero. */
+
+ NORMAL_CHAR:
+ default:
+ length += 2;
+ runlength = 0;
+ do
+ {
+ if ((options & PCRE_EXTENDED) != 0)
+ {
+ if ((compile_block.ctypes[c] & ctype_space) != 0)
+ continue;
+ if (c == '#')
+ {
+ /* The space before the ; is to avoid a warning on a silly compiler
+ on the Macintosh. */
+ while ((c = *(++ptr)) != 0 && c != '\n');
+ continue;
+ }
+ }
+
+ /* Backslash may introduce a data char or a metacharacter; stop the
+ string before the latter. */
+
+ if (c == '\\')
+ {
+ const uschar *saveptr = ptr;
+ c = check_escape (&ptr, errorptr, bracount, options, FALSE,
+ &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if (c < 0)
+ {
+ ptr = saveptr - 1;
+ c = '\\';
+ break;
+ }
+ }
+
+ /* Ordinary character or single-char escape */
+ runlength++;
+ c = 0;
+ }
+
+ /* This "while" is the end of the "do" above. */
+
+ while (runlength < MAXLIT && ptr <= compile_block.end &&
+ (compile_block.ctypes[c = *(++ptr)] & ctype_meta) == 0);
+
+ if (compile_block.ctypes[c] & ctype_meta)
+ ptr--;
+ length += runlength;
+ continue;
+ }
+ }
+
+ length += 4; /* For final KET and END */
+
+ if (length > 65539)
+ {
+ *errorptr = pcre_estrings[20];
+ return NULL;
+ }
+
+ /* Compute the size of data block needed and get it, either from malloc or
+ externally provided function. We specify "code[0]" in the offsetof() expression
+ rather than just "code", because it has been reported that one broken compiler
+ fails on "code" because it is also an independent variable. It should make no
+ difference to the value of the offsetof(). */
+ size = length + offsetof (pcre, code[0]);
+ re = (pcre *) (pcre_malloc) (size);
+
+ if (re == NULL)
+ {
+ *errorptr = pcre_estrings[21];
+ return NULL;
+ }
+
+ /* Put in the magic number, and save the size, options, and table pointer */
+ re->magic_number = MAGIC_NUMBER;
+ re->size = size;
+ re->options = options;
+ re->tables = tables;
+
+ /* Set up a starting, non-capturing bracket, then compile the expression. On
+ error, *errorptr will be set non-NULL, so we don't need to look at the result
+ of the function here. */
+ ptr = (const uschar *) pattern;
+ code = re->code;
+ *code = OP_BRA;
+ bracount = 0;
+ (void) compile_regex (options, -1, &bracount, &code, &ptr, errorptr, FALSE,
+ 0, &reqchar, &countlits, &compile_block, compile_branch_perl);
+ re->top_bracket = bracount;
+ re->top_backref = top_backref;
+
+ /* If not reached end of pattern on success, there's an excess bracket. */
+ if (*errorptr == NULL && ptr <= compile_block.end)
+ *errorptr = pcre_estrings[22];
+
+ /* Fill in the terminating state and check for disastrous overflow, but
+ if debugging, leave the test till after things are printed out. */
+ *code++ = OP_END;
+
+#ifndef DEBUG
+ if (code - re->code > length)
+ *errorptr = pcre_estrings[23];
+#endif
+
+ /* Give an error if there's back reference to a non-existent capturing
+ subpattern. */
+ if (top_backref > re->top_bracket)
+ *errorptr = pcre_estrings[15];
+
+/* Failed to compile */
+
+ if (*errorptr != NULL)
+ {
+ (pcre_free) (re);
+ PCRE_ERROR_RETURN:
+ *erroroffset = ptr - (const uschar *) pattern;
+ return NULL;
+ }
+
+ /* If the anchored option was not passed, set flag if we can determine that the
+ pattern is anchored by virtue of ^ characters or \A or anything else (such as
+ starting with .* when DOTALL is set).
+
+ Otherwise, see if we can determine what the first character has to be, because
+ that speeds up unanchored matches no end. If not, see if we can set the
+ PCRE_STARTLINE flag. This is helpful for multiline matches when all branches
+ start with ^. and also when all branches start with .* for non-DOTALL matches.
+ */
+ if ((options & PCRE_ANCHORED) == 0)
+ {
+ int temp_options = options;
+ if (is_anchored (re->code, &temp_options))
+ re->options |= PCRE_ANCHORED;
+ else
+ {
+ int ch = find_firstchar (re->code, &temp_options);
+ if (ch >= 0)
+ {
+ re->first_char = ch;
+ re->options |= PCRE_FIRSTSET;
+ }
+ else if (is_startline (re->code))
+ re->options |= PCRE_STARTLINE;
+ }
+ }
+
+ /* Save the last required character if there are at least two literal
+ characters on all paths, or if there is no first character setting. */
+ if (reqchar >= 0 && (countlits > 1 || (re->options & PCRE_FIRSTSET) == 0))
+ {
+ re->req_char = reqchar;
+ re->options |= PCRE_REQCHSET;
+ }
+
+ re->max_match_size = -1;
+
+ /* Print out the compiled data for debugging */
+#ifdef DEBUG
+ pcre_debug (re);
+
+ if (code - re->code > length)
+ {
+ *errorptr = pcre_estrings[23];
+ (pcre_free) (re);
+ *erroroffset = ptr - (uschar *) pattern;
+ return NULL;
+ }
+#endif
+
+ if (*errorptr && (options & PCRE_ENGLISH_ERRORS) == 0)
+ *errorptr = gettext(*errorptr);
+
+ return (pcre *) re;
+}
diff --git a/pcre/regposix.c b/pcre/regposix.c
new file mode 100644
index 0000000..cc7d901
--- /dev/null
+++ b/pcre/regposix.c
@@ -0,0 +1,1921 @@
+
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ ----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+
+/* Include the internals header, which itself includes Standard C headers plus
+ the external pcre header. */
+
+#include "internal.h"
+
+/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
+ inline, and there are *still* stupid compilers about that don't like indented
+ pre-processor statements. I suppose it's only been 10 years... */
+
+#ifdef DEBUG
+#define DPRINTF(p) printf p
+#define DFWRITE(p) fwrite p
+#else
+#define DPRINTF(p) /*nothing */
+#define DFWRITE(p) /*nothing */
+#endif
+
+
+/* Allow compilation as C++ source code, should anybody want to do that. */
+
+#ifdef __cplusplus
+#define class pcre_class
+#endif
+
+
+/* Maximum number of items on the nested bracket stacks at compile time. This
+ applies to the nesting of all kinds of parentheses. It does not limit
+ un-nested, non-capturing parentheses. This number can be made bigger if
+ necessary - it is used to dimension one int and one unsigned char vector at
+ compile time. */
+
+#define BRASTACK_SIZE 200
+
+
+/* The number of bytes in a literal character string above which we can't
+ add any more. */
+
+#define MAXLIT 255
+
+/* Text forms of OP_ values and things, for debugging (not all used) */
+
+/* Table for handling escaped characters in the range ' '-'z'. Positive returns
+ are simple data values; negative values are for special things like \d and so
+ on. Zero means further processing is needed (for things like \x), or the escape
+ is invalid. */
+
+static const short int escapes[] = {
+ 0, 0, 0, 0, 0, 0, 0, -ESC_z, /* space - ' */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* ( - / */
+ 0, -ESC_REF - 1, -ESC_REF - 2, /* 0 - 8 */
+ -ESC_REF - 3, -ESC_REF - 4, -ESC_REF - 5,
+ -ESC_REF - 6, -ESC_REF - 7, -ESC_REF - 8,
+ -ESC_REF - 9, ':', ';', -ESC_LESS, '=', -ESC_GREATER, '?', /* 9 - ? */
+ '@', 0, -ESC_B, 0, 0, 0, 0, -ESC_G, /* @ - G */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
+ 0, 0, 0, -ESC_S, 0, 0, 0, -ESC_W, /* P - W */
+ 0, 0, 0, '[', '\\', ']', '^', '_', /* X - _ */
+ -ESC_A, 7, -ESC_b, 0, 0, 27, '\f', 0, /* ` - g */
+ 0, 0, 0, 0, 0, 0, '\n', 0, /* h - o */
+ 0, 0, '\r', -ESC_s, '\t', 0, '\v', -ESC_w, /* p - w */
+ 0, 0, 0 /* x - z */
+};
+
+#include "regcomp.c"
+
+
+/*************************************************
+* Handle escapes *
+*************************************************/
+
+/* This function is called when a \ has been encountered. It either returns a
+ positive value for a simple escape such as \n, or a negative value which
+ encodes one of the more complicated things such as \d. On entry, ptr is
+ pointing at the \. On exit, it is on the final character of the escape
+ sequence.
+
+ Arguments:
+ ptrptr points to the pattern position pointer
+ errorptr points to the pointer to the error message
+ bracount number of previous capturing brackets
+ options the options bits
+ isclass TRUE if inside a character class
+ cd pointer to char tables block
+
+ Returns: zero or positive => a data character
+ negative => a special escape sequence
+ on error, errorptr is set
+ */
+
+static int
+check_escape (ptrptr, errorptr, bracount, options, isclass, cd)
+ const uschar **ptrptr;
+ const char **errorptr;
+ int bracount;
+ int options;
+ BOOL isclass;
+ compile_data *cd;
+{
+ const uschar *ptr = *ptrptr;
+ int c, i;
+
+ c = *(++ptr);
+
+ /* Digits or letters may have special meaning; all others are literals. */
+ if (c < ' ' || c > 'z')
+ {
+ if (isclass) {
+ c = '\\';
+ --ptr;
+ }
+ }
+
+ /* Do an initial lookup in a table. A > zero result is something that can be
+ returned immediately. A < zero is a literal inside a class, a special
+ operator outside brackets. Otherwise further processing may be required. */
+ else if (((i = escapes[c - ' ']) < 0 || i == c) && isclass)
+ {
+ c = '\\';
+ --ptr;
+ }
+
+ else if (i != 0)
+ c = i;
+
+ /* Escapes that need further processing, or are illegal. */
+ else
+ {
+ const uschar *oldptr;
+ switch (c)
+ {
+ case 'o':
+ if (ptr == cd->end || (cd->ctypes[ptr[1]] & ctype_digit) == 0 ||
+ ptr[1] == '8' || ptr[1] == '9')
+ break;
+
+ c = 0;
+ do
+ c = c * 8 + *(++ptr) - '0';
+ while (++i < 3 && ptr < cd->end
+ && (cd->ctypes[ptr[1]] & ctype_digit) != 0 &&
+ ptr[1] != '8' && ptr[1] != '9');
+
+ c &= 255; /* Take least significant 8 bits */
+ break;
+
+ case 'd':
+ if (ptr == cd->end || (cd->ctypes[ptr[1]] & ctype_digit) == 0)
+ break;
+
+ c = 0;
+ do
+ c = c * 10 + *(++ptr) - '0';
+ while (++i < 3 && ptr < cd->end
+ && (cd->ctypes[ptr[1]] & ctype_digit) != 0);
+
+ c &= 255; /* Take least significant 8 bits */
+ break;
+
+ case 'x':
+ /* Read just a single hex char */
+ if (ptr == cd->end || (cd->ctypes[ptr[1]] & ctype_xdigit) == 0)
+ break;
+
+ c = 0;
+ do
+ {
+ ptr++;
+ c = c * 16 + cd->lcc[*ptr] -
+ (((cd->ctypes[*ptr] & ctype_digit) != 0) ? '0' : 'a' - 10);
+ }
+ while (++i < 2 && ptr < cd->end
+ && (cd->ctypes[ptr[1]] & ctype_xdigit) != 0);
+ break;
+
+ case 'c':
+ if ((++ptr) > cd->end || (c = *ptr) == 0)
+ {
+ *errorptr = pcre_estrings[2];
+ return 0;
+ }
+
+ /* A letter is upper-cased; then the 0x40 bit is flipped */
+
+ if (c >= 'a' && c <= 'z')
+ c = cd->fcc[c];
+ c ^= 0x40;
+ break;
+
+ default:
+ if (isclass)
+ {
+ c = '\\';
+ --ptr;
+ }
+
+ break;
+ }
+ }
+
+ *ptrptr = ptr;
+ return c;
+}
+
+
+
+/*************************************************
+* Compile one branch *
+*************************************************/
+
+/* Scan the pattern, compiling it into the code vector.
+
+ Arguments:
+ options the option bits
+ brackets points to number of capturing brackets used
+ code points to the pointer to the current code point
+ ptrptr points to the current pattern pointer
+ errorptr points to pointer to error message
+ optchanged set to the value of the last OP_OPT item compiled
+ reqchar set to the last literal character required, else -1
+ countlits set to count of mandatory literal characters
+ cd contains pointers to tables
+
+ Returns: TRUE on success
+ FALSE, with *errorptr set on error
+ */
+
+static BOOL
+compile_branch_posix (options, brackets, codeptr, ptrptr, errorptr, optchanged,
+ reqchar, countlits, cd)
+ int options;
+ int *brackets;
+ uschar **codeptr;
+ const uschar **ptrptr;
+ const char **errorptr;
+ int *optchanged;
+ int *reqchar;
+ int *countlits;
+ compile_data *cd;
+{
+ int repeat_min, repeat_max;
+ int bravalue, length;
+ int greedy_default;
+ int prevreqchar;
+ int condcount = 0;
+ int subcountlits = 0;
+ BOOL first = TRUE;
+ register int c;
+ register uschar *code = *codeptr;
+ uschar *tempcode;
+ const uschar *ptr = *ptrptr;
+ const uschar *tempptr;
+ uschar *previous = NULL;
+ uschar class[32];
+
+ /* Set up the settings for greediness */
+ greedy_default = ((options & PCRE_UNGREEDY) != 0);
+
+ /* Initialize no required char, and count of literals */
+ *reqchar = prevreqchar = -1;
+ *countlits = 0;
+
+ /* Initialize standard {1,1} repeats */
+ repeat_min = repeat_max = 1;
+
+ /* Switch on next character until the end of the branch */
+ for (;; first = FALSE, ptr++)
+ {
+ BOOL negate_class;
+ int class_charcount;
+ int class_lastchar;
+ int newoptions;
+ int skipbytes;
+ int subreqchar;
+
+ c = (ptr > cd->end) ? 0 : *ptr;
+
+ if ((repeat_min != 1 || repeat_max != 1) &&
+ (c != '*' && c != '+' && c != '?' && c != '{'))
+ {
+ int op_type;
+ int repeat_type;
+
+ if (*previous == OP_CIRC || *previous == OP_DOLL ||
+ (*previous >= ESC_LESS && *previous < ESC_FIRST_CONSUME) ||
+ (*previous > ESC_LAST_CONSUME && *previous <= ESC_z))
+ {
+ /* Handle assertions: ^* --> , ^{1,3} --> ^ */
+ if (repeat_min == 0)
+ code = previous;
+ goto END_REPEAT;
+ }
+
+ repeat_type = greedy_default;
+
+ /* If previous was a string of characters, chop off the last one and use it
+ as the subject of the repeat. If there was only one character, we can
+ abolish the previous item altogether. A repeat with a zero minimum wipes
+ out any reqchar setting, backing up to the previous value. We must also
+ adjust the countlits value. */
+
+ if (*previous == OP_CHARS)
+ {
+ int len = previous[1];
+
+ if (repeat_min == 0)
+ *reqchar = prevreqchar;
+ *countlits += repeat_min - 1;
+
+ if (len == 1)
+ {
+ c = previous[2];
+ code = previous;
+ }
+ else
+ {
+ c = previous[len + 1];
+ previous[1]--;
+ code--;
+ }
+ op_type = 0; /* Use single-char op codes */
+ goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */
+ }
+
+ /* If previous was a single negated character ([^a] or similar), we use
+ one of the special opcodes, replacing it. The code is shared with single-
+ character repeats by adding a suitable offset into repeat_type. */
+
+ else if ((int) *previous == OP_NOT)
+ {
+ op_type = OP_NOT - OP_CHARS; /* Use "not" opcodes */
+ c = previous[1];
+ code = previous;
+ goto OUTPUT_SINGLE_REPEAT;
+ }
+
+ /* If previous was a character type match (\d or similar), abolish it and
+ create a suitable repeat item. The code is shared with single-character
+ repeats by adding a suitable offset into repeat_type. */
+
+ else if (*previous == OP_TYPE || *previous == OP_TYPENOT ||
+ *previous == OP_ANY)
+ {
+ if (*previous == OP_ANY)
+ {
+ c = 0;
+ *previous = OP_TYPENOT;
+ }
+ else
+ c = previous[1];
+
+ op_type = *previous - OP_CHARS;
+ code = previous;
+
+ OUTPUT_SINGLE_REPEAT:
+ cd->max_match_size += repeat_max - 1;
+
+ /* If the maximum is zero then the minimum must also be zero; Perl allows
+ this case, so we do too - by simply omitting the item altogether. */
+
+ if (repeat_max == 0)
+ goto END_REPEAT;
+
+ /* Combine the op_type with the repeat_type */
+
+ repeat_type += op_type;
+
+ /* A minimum of zero is handled either as the special case * or ?, or as
+ an UPTO, with the maximum given. */
+
+ if (repeat_min == 0)
+ {
+ if (repeat_max == -1)
+ *code++ = OP_MAXSTAR + repeat_type;
+ else if (repeat_max == 1)
+ *code++ = OP_MAXQUERY + repeat_type;
+ else
+ {
+ *code++ = OP_MAXUPTO + repeat_type;
+ *code++ = repeat_max >> 8;
+ *code++ = (repeat_max & 255);
+ }
+ }
+
+ /* The case {1,} is handled as the special case + */
+
+ else if (repeat_min == 1 && repeat_max == -1)
+ *code++ = OP_MAXPLUS + repeat_type;
+
+ /* The case {n,n} is just an EXACT, while the general case {n,m} is
+ handled as an EXACT followed by an UPTO. An EXACT of 1 is optimized. */
+
+ else
+ {
+ if (repeat_min != 1)
+ {
+ *code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */
+ *code++ = repeat_min >> 8;
+ *code++ = (repeat_min & 255);
+ }
+
+ /* If the mininum is 1 and the previous item was a character string,
+ we either have to put back the item that got cancelled if the string
+ length was 1, or add the character back onto the end of a longer
+ string. For a character type nothing need be done; it will just get
+ put back naturally. Note that the final character is always going to
+ get added below. */
+
+ else if (*previous == OP_CHARS)
+ {
+ if (code == previous)
+ code += 2;
+ else
+ previous[1]++;
+ }
+
+ /* For negated characters or classes we also have to put back the
+ item that got cancelled. */
+
+ else if (*previous == OP_NOT || *previous == OP_TYPE ||
+ *previous == OP_TYPENOT)
+ code++;
+ /* If the maximum is unlimited, insert an OP_MAXSTAR. */
+
+ if (repeat_max < 0)
+ {
+ *code++ = c;
+ *code++ = OP_MAXSTAR + repeat_type;
+ }
+
+ /* Else insert an UPTO if the max is greater than the min. */
+
+ else if (repeat_max != repeat_min)
+ {
+ *code++ = c;
+ repeat_max -= repeat_min;
+ *code++ = OP_MAXUPTO + repeat_type;
+ *code++ = repeat_max >> 8;
+ *code++ = (repeat_max & 255);
+ }
+ }
+
+ /* The character or character type itself comes last in all cases. */
+
+ *code++ = c;
+ }
+
+ /* If previous was a character class or a back reference, we put the repeat
+ stuff after it, but just skip the item if the repeat was {0,0}. */
+
+ else if (*previous == OP_CLASS || *previous == OP_REF)
+ {
+ if (repeat_max == 0)
+ {
+ code = previous;
+ goto END_REPEAT;
+ }
+
+ if (*previous == OP_CLASS)
+ cd->max_match_size += repeat_max - 1;
+ else
+ repeat_type += OP_REF - OP_CLASS;
+
+ if (repeat_min == 0 && repeat_max == -1)
+ *previous = OP_CL_MAXSTAR + repeat_type;
+ else if (repeat_min == 1 && repeat_max == -1)
+ *previous = OP_CL_MAXPLUS + repeat_type;
+ else if (repeat_min == 0 && repeat_max == 1)
+ *previous = OP_CL_MAXQUERY + repeat_type;
+ else
+ {
+ *previous = OP_CL_MAXRANGE + repeat_type;
+ *code++ = repeat_min >> 8;
+ *code++ = repeat_min & 255;
+ if (repeat_max == -1)
+ repeat_max = 0; /* 2-byte encoding for max */
+ *code++ = repeat_max >> 8;
+ *code++ = repeat_max & 255;
+ }
+ }
+
+ /* If previous was a bracket group, we may have to replicate it in certain
+ cases. */
+
+ else if ((int) *previous >= OP_BRA || (int) *previous == OP_ONCE ||
+ (int) *previous == OP_COND)
+ {
+ register int i;
+ int ketoffset = 0;
+ int len = code - previous;
+
+ /* If the maximum repeat count is unlimited, find the end of the bracket
+ by scanning through from the start, and compute the offset back to it
+ from the current code pointer. There may be an OP_OPT setting following
+ the final KET, so we can't find the end just by going back from the code
+ pointer. */
+
+ if (repeat_max == -1)
+ {
+ register uschar *ket = previous;
+ do
+ ket += (ket[1] << 8) + ket[2];
+ while (*ket != OP_KET);
+ ketoffset = code - ket;
+ }
+ else
+ cd->max_match_size += subcountlits * (repeat_max - 1);
+
+ /* The case of a zero minimum is special because of the need to stick
+ OP_BRAZERO in front of it, and because the group appears once in the
+ data, whereas in other cases it appears the minimum number of times. For
+ this reason, it is simplest to treat this case separately, as otherwise
+ the code gets far too messy. There are several special subcases when the
+ minimum is zero. */
+
+ if (repeat_min == 0)
+ {
+ /* If we set up a required char from the bracket, we must back off
+ to the previous value and reset the countlits value too. */
+
+ if (subcountlits > 0)
+ {
+ *reqchar = prevreqchar;
+ *countlits -= subcountlits;
+ }
+
+ /* If the maximum is also zero, we just omit the group from the output
+ altogether. */
+
+ if (repeat_max == 0)
+ {
+ code = previous;
+ goto END_REPEAT;
+ }
+
+ /* If the maximum is 1 or unlimited, we just have to stick in the
+ BRAZERO and do no more at this point. */
+
+ if (repeat_max <= 1)
+ {
+ memmove (previous + 1, previous, len);
+ code++;
+ *previous++ = OP_BRAZERO + repeat_type;
+ }
+
+ /* If the maximum is greater than 1 and limited, we have to replicate
+ in a nested fashion, sticking OP_BRAZERO before each set of brackets.
+ The first one has to be handled carefully because it's the original
+ copy, which has to be moved up. The remainder can be handled by code
+ that is common with the non-zero minimum case below. We just have to
+ adjust the value or repeat_max, since one less copy is required. */
+
+ else
+ {
+ int offset;
+ memmove (previous + 1, previous, len);
+ code += 1;
+ *previous++ = OP_BRAZERO + repeat_type;
+ }
+
+ repeat_max--;
+ }
+
+ /* If the minimum is greater than zero, replicate the group as many
+ times as necessary, and adjust the maximum to the number of subsequent
+ copies that we need. */
+
+ else
+ {
+ for (i = 1; i < repeat_min; i++)
+ {
+ memcpy (code, previous, len);
+ code += len;
+ }
+ if (repeat_max > 0)
+ repeat_max -= repeat_min;
+ }
+
+ /* This code is common to both the zero and non-zero minimum cases. If
+ the maximum is limited, it replicates the group in a nested fashion,
+ remembering the bracket starts on a stack. In the case of a zero minimum,
+ the first one was set up above. In all cases the repeat_max now specifies
+ the number of additional copies needed. */
+
+ if (repeat_max >= 0)
+ {
+ for (i = repeat_max - 1; i >= 0; i--)
+ {
+ *code++ = OP_BRAZERO + repeat_type;
+
+ memcpy (code, previous, len);
+ code += len;
+ }
+ }
+
+ /* If the maximum is unlimited, set a repeater in the final copy. We
+ can't just offset backwards from the current code point, because we
+ don't know if there's been an options resetting after the ket. The
+ correct offset was computed above. */
+
+ else
+ code[-ketoffset] = OP_KET_MAXSTAR + repeat_type;
+ }
+
+ /* Else there's some kind of shambles */
+
+ else
+ {
+ *errorptr = pcre_estrings[11];
+ goto FAILED;
+ }
+
+
+ if (repeat_max == -1)
+ /* An unlimited repeat forces us to disable this optimization */
+ cd->max_match_size = INT_MIN;
+
+ /* In all case we no longer have a previous item. */
+
+ END_REPEAT:
+ previous = NULL;
+ repeat_min = 1;
+ repeat_max = 1;
+ }
+
+ if (ptr > cd->end)
+ break;
+
+ c = *ptr;
+
+ switch (c)
+ {
+ /* The branch terminates at end of string, |, or ). */
+
+ case '|':
+ case ')':
+ goto SUCCEEDED;
+
+ /* Handle single-character metacharacters */
+
+ case '^':
+ if (!first)
+ goto NORMAL_CHAR;
+ previous = code;
+ *code++ = OP_CIRC;
+ break;
+
+ case '$':
+ if (ptr < cd->end && ptr[1] != '|' && ptr[1] != ')')
+ goto NORMAL_CHAR;
+ previous = NULL;
+ /* Perl has different semantics than POSIX for dollars, when
+ multiline mode is not in effect */
+ *code++ = (options & PCRE_MULTILINE) ? OP_DOLL : OP_EOD;
+ break;
+
+ case '.':
+ previous = code;
+ cd->max_match_size++;
+ *code++ = OP_ANY;
+ break;
+
+ /* Character classes. These always build a 32-byte bitmap of the permitted
+ characters, except in the special case where there is only one character.
+ For negated classes, we build the map as usual, then invert it at the end.
+ */
+
+ case '[':
+ previous = code;
+ cd->max_match_size++;
+ *code++ = OP_CLASS;
+
+ /* If the first character is '^', set the negation flag and skip it. */
+
+ if ((c = *(++ptr)) == '^')
+ {
+ negate_class = TRUE;
+ c = *(++ptr);
+ }
+ else
+ negate_class = FALSE;
+
+ /* Keep a count of chars so that we can optimize the case of just a single
+ character. */
+
+ class_charcount = 0;
+ class_lastchar = -1;
+
+ /* Initialize the 32-char bit map to all zeros. We have to build the
+ map in a temporary bit of store, in case the class contains only 1
+ character, because in that case the compiled code doesn't use the
+ bit map. */
+
+ memset (class, 0, 32 * sizeof (uschar));
+
+ /* Process characters until ] is reached. By writing this as a "do" it
+ means that an initial ] is taken as a data character. We also have
+ to take care of this in the `if' below: it is an error if we reach the
+ last character and we have not added a data character yet, because a
+ closing bracket will not be considered as a terminator. */
+
+ do
+ {
+ if (ptr > cd->end
+ || (ptr == cd->end && *ptr != ']')
+ || (ptr == cd->end && class_charcount == 0))
+ {
+ *errorptr = pcre_estrings[6];
+ goto FAILED;
+ }
+
+ /* Handle POSIX class names. A square bracket that doesn't match the
+ syntax is treated as a literal. We also recognize the POSIX
+ constructions [.ch.] and [=ch=] ("collating elements") and
+ fault them, as Perl 5.6 does. */
+
+ if (c == '[' &&
+ (ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
+ check_posix_syntax (ptr, &tempptr, cd))
+ {
+ int posix_class, i;
+ register const uschar *cbits = cd->cbits;
+
+ if (ptr[1] != ':')
+ {
+ *errorptr = pcre_estrings[31];
+ goto FAILED;
+ }
+
+ ptr += 2;
+
+ posix_class = check_posix_name (ptr, tempptr - ptr);
+ if (posix_class < 0)
+ {
+ *errorptr = pcre_estrings[30];
+ goto FAILED;
+ }
+
+ /* If matching is caseless, upper and lower are converted to
+ alpha. This relies on the fact that the class table starts with
+ alpha, lower, upper as the first 3 entries. */
+
+ if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
+ posix_class = 0;
+
+ /* Or into the map we are building up to 3 of the static class
+ tables, or their negations. */
+
+ posix_class *= 3;
+ for (i = 0; i < 3; i++)
+ {
+ int taboffset = posix_class_maps[posix_class + i];
+ if (taboffset < 0)
+ break;
+ for (c = 0; c < 32; c++)
+ class[c] |= cbits[c + taboffset];
+ }
+
+ ptr = tempptr + 1;
+ class_charcount = 10; /* Set > 1; assumes more than 1 per class */
+ continue;
+ }
+
+ /* Escapes inside character classes are not POSIX */
+ if (c == '\\')
+ c =
+ check_escape (&ptr, errorptr, *brackets, options, TRUE, cd);
+
+ /* A single character may be followed by '-' to form a range. However,
+ Perl and POSIX do not permit ']' to be the end of the range. An hyphen
+ here is treated as a literal. */
+
+ if (ptr[1] == '-' && ptr[2] != ']')
+ {
+ int d;
+ ptr += 2;
+
+ if (ptr > cd->end)
+ {
+ *errorptr = pcre_estrings[6];
+ goto FAILED;
+ }
+
+ d = *ptr;
+ if (d == '\\')
+ d =
+ check_escape (&ptr, errorptr, *brackets, options, TRUE,
+ cd);
+
+ if (d < c)
+ {
+ *errorptr = pcre_estrings[8];
+ goto FAILED;
+ }
+
+ for (; c <= d; c++)
+ {
+ class[c / 8] |= (1 << (c & 7));
+ if ((options & PCRE_CASELESS) != 0)
+ {
+ int uc = cd->fcc[c]; /* flip case */
+ class[uc / 8] |= (1 << (uc & 7));
+ }
+ class_charcount++; /* in case a one-char range */
+ class_lastchar = c;
+ }
+ continue; /* Go get the next char in the class */
+ }
+
+ /* Handle a lone single character */
+
+ class[c / 8] |= (1 << (c & 7));
+ if ((options & PCRE_CASELESS) != 0)
+ {
+ c = cd->fcc[c]; /* flip case */
+ class[c / 8] |= (1 << (c & 7));
+ }
+ class_charcount++;
+ class_lastchar = c;
+ }
+
+ /* Loop until ']' reached; the check for end of string happens inside the
+ loop. This "while" is the end of the "do" above. */
+
+ while ((c = *(++ptr)) != ']');
+
+ /* If class_charcount is 1 and class_lastchar is not negative, we saw
+ precisely one character. This doesn't need the whole 32-byte bit map.
+ We turn it into a 1-character OP_CHAR if it's positive, or OP_NOT if
+ it's negative. */
+
+ if (class_charcount == 1 && class_lastchar >= 0)
+ {
+ if (negate_class)
+ {
+ code[-1] = OP_NOT;
+ }
+ else
+ {
+ code[-1] = OP_CHARS;
+ *code++ = 1;
+ }
+ *code++ = class_lastchar;
+ }
+
+ /* Otherwise, negate the 32-byte map if necessary, and copy it into
+ the code vector. */
+
+ else
+ {
+ if (negate_class)
+ for (c = 0; c < 32; c++)
+ code[c] = ~class[c];
+ else
+ memcpy (code, class, 32);
+ code += 32;
+ }
+ break;
+
+ /* Various kinds of repeat */
+
+ case '{':
+ if (previous == NULL)
+ goto NORMAL_CHAR;
+
+ if (!is_counted_repeat (ptr + 1, cd))
+ *errorptr = pcre_estrings[14];
+ else
+ {
+ ptr = read_repeat_counts (ptr + 1, &repeat_min, &repeat_max,
+ errorptr, cd);
+ if (*errorptr != NULL)
+ goto FAILED;
+ }
+ break;
+
+ case '*':
+ if (previous == NULL)
+ goto NORMAL_CHAR;
+
+ repeat_min = 0;
+ repeat_max = -1;
+ break;
+
+ case '+':
+ if (previous == NULL)
+ goto NORMAL_CHAR;
+
+ repeat_max = -1;
+ break;
+
+ case '?':
+ if (previous == NULL)
+ goto NORMAL_CHAR;
+
+ repeat_min = 0;
+ break;
+
+ /* Start of nested bracket sub-expression. */
+
+ case '(':
+ newoptions = options;
+ skipbytes = 0;
+ if (ptr == cd->end)
+ {
+ *errorptr = pcre_estrings[22];
+ goto FAILED;
+ }
+
+ /* In POSIX we always have a referencing group; adjust the opcode. If the bracket
+ number is greater than EXTRACT_BASIC_MAX, we set the opcode one higher, and
+ arrange for the true number to follow later, in an OP_BRANUMBER item. */
+
+ ptr++;
+ if (++(*brackets) > EXTRACT_BASIC_MAX)
+ {
+ bravalue = OP_BRA + EXTRACT_BASIC_MAX + 1;
+ code[3] = OP_BRANUMBER;
+ code[4] = *brackets >> 8;
+ code[5] = *brackets & 255;
+ skipbytes = 3;
+ }
+ else
+ bravalue = OP_BRA + *brackets;
+
+ /* Process nested bracketed re. Assertions may not be repeated, but other
+ kinds can be. We copy code into a non-register variable in order to be able
+ to pass its address because some compilers complain otherwise. Pass in a
+ new setting for the ims options if they have changed. */
+
+ previous = code;
+ *code = bravalue;
+ tempcode = code;
+
+ if (!compile_regex (options | PCRE_INGROUP, /* Set for all nested groups */
+ ((options & PCRE_IMS) !=
+ (newoptions & PCRE_IMS)) ? newoptions &
+ PCRE_IMS : -1, /* Pass ims options if changed */
+ brackets, /* Capturing bracket count */
+ &tempcode, /* Where to put code (updated) */
+ &ptr, /* Input pointer (updated) */
+ errorptr, /* Where to put an error message */
+ FALSE, /* Whether this is a lookbehind assertion */
+ skipbytes, /* Skip over OP_COND/OP_BRANUMBER */
+ &subreqchar, /* For possible last char */
+ &subcountlits, /* For literal count */
+ cd, /* Tables block */
+ compile_branch_posix))
+ goto FAILED;
+
+ /* At the end of compiling, code is still pointing to the start of the
+ group, while tempcode has been updated to point past the end of the group
+ and any option resetting that may follow it. The pattern pointer (ptr)
+ is on the bracket. */
+
+ /* If this is a conditional bracket, check that there are no more than
+ two branches in the group. */
+
+ else if (bravalue == OP_COND)
+ {
+ uschar *tc = code;
+ condcount = 0;
+
+ do
+ {
+ condcount++;
+ tc += (tc[1] << 8) | tc[2];
+ }
+ while (*tc != OP_KET);
+
+ if (condcount > 2)
+ {
+ *errorptr = pcre_estrings[27];
+ goto FAILED;
+ }
+ }
+
+ /* Handle updating of the required character. If the subpattern didn't
+ set one, leave it as it was. Otherwise, update it for normal brackets of
+ all kinds, forward assertions, and conditions with two branches. Don't
+ update the literal count for forward assertions, however. If the bracket
+ is followed by a quantifier with zero repeat, we have to back off. Hence
+ the definition of prevreqchar and subcountlits outside the main loop so
+ that they can be accessed for the back off. */
+
+ if (subreqchar > 0 &&
+ (bravalue >= OP_BRA || bravalue == OP_ONCE
+ || bravalue == OP_ASSERT || (bravalue == OP_COND
+ && condcount == 2)))
+ {
+ prevreqchar = *reqchar;
+ *reqchar = subreqchar;
+ if (bravalue != OP_ASSERT)
+ *countlits += subcountlits;
+ }
+
+ /* Now update the main code pointer to the end of the group. */
+
+ code = tempcode;
+
+ /* Error if hit end of pattern */
+
+ if (ptr > cd->end || *ptr != ')')
+ {
+ *errorptr = pcre_estrings[14];
+ goto FAILED;
+ }
+ break;
+
+ /* Check \ for being a real metacharacter; if not, fall through and handle
+ it as a data character at the start of a string. Escape items are checked
+ for validity in the pre-compiling pass. */
+
+ case '\\':
+ tempptr = ptr;
+ c = check_escape (&ptr, errorptr, *brackets, options, FALSE, cd);
+
+ /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values
+ are arranged to be the negation of the corresponding OP_values. For the
+ back references, the values are ESC_REF plus the reference number. Only
+ back references and those types that consume a character may be repeated. */
+
+ if (c < 0)
+ {
+ c = -c;
+ if (c >= ESC_REF)
+ {
+ int number = c - ESC_REF;
+ previous = code;
+ *code++ = OP_REF;
+ *code++ = number >> 8;
+ *code++ = number & 255;
+ }
+ else if (c >= ESC_FIRST_CONSUME && c <= ESC_LAST_CONSUME)
+ {
+ c -= ESC_FIRST_CONSUME;
+ previous = code;
+ *code++ = (c & 1) ? OP_TYPE : OP_TYPENOT;
+ *code++ = (c >> 1) + 1;
+ }
+ else
+ {
+ previous = NULL;
+ *code++ = c;
+ }
+ continue;
+ }
+
+ /* Data character: reset and fall through */
+
+ ptr = tempptr;
+ c = '\\';
+
+ /* Handle a run of data characters until a metacharacter is encountered.
+ The first character is guaranteed not to be whitespace or # when the
+ extended flag is set. */
+
+ NORMAL_CHAR:
+ default:
+ previous = code;
+ *code = OP_CHARS;
+ code += 2;
+ length = 0;
+
+ do
+ {
+ /* Backslash may introduce a data char or a metacharacter. Escaped items
+ are checked for validity in the pre-compiling pass. Stop the string
+ before a metaitem. */
+
+ if (c == '\\')
+ {
+ tempptr = ptr;
+ c =
+ check_escape (&ptr, errorptr, *brackets, options,
+ FALSE, cd);
+ if (c < 0)
+ {
+ ptr = tempptr - 1;
+ c = '\\';
+ break;
+ }
+ }
+
+ /* Ordinary character or single-char escape */
+
+ *code++ = c;
+ cd->max_match_size++;
+ length++;
+ c = 0;
+ }
+
+ /* This "while" is the end of the "do" above. */
+
+ while (length < MAXLIT && ptr < cd->end &&
+ (cd->ctypes[c = *(++ptr)] & ctype_meta) == 0);
+
+ /* Update the last character and the count of literals */
+
+ prevreqchar = (length > 1) ? code[-2] : *reqchar;
+ *reqchar = code[-1];
+ *countlits += length;
+
+ /* Compute the length and set it in the data vector, and advance to
+ the next state. */
+
+ previous[1] = length;
+ if (cd->ctypes[c] & ctype_meta)
+ ptr--;
+ break;
+ }
+ } /* end of big loop */
+
+SUCCEEDED:
+ *codeptr = code;
+ *ptrptr = ptr;
+ return TRUE;
+
+ /* Control never reaches here by falling through, only by a goto for all the
+ error states. Pass back the position in the pattern so that it can be displayed
+ to the user for diagnosing the error. */
+
+FAILED:
+ *ptrptr = ptr;
+ return FALSE;
+}
+
+
+
+/************************************************
+* Handle Basic Regular Expressions *
+*************************************************/
+
+
+
+char *
+basic_to_extended_regexp (s, patlen)
+ const char *s;
+ int *patlen;
+{
+ char *d, *base;
+ const char *start, *end;
+ int literal;
+
+ start = s;
+ base = d = (pcre_malloc) (*patlen * 2 + 1);
+ end = s + *patlen;
+
+ while (s < end)
+ switch (*s)
+ {
+ case '\\':
+ s++;
+ if (s == end)
+ {
+ *d++ = '\\';
+ break;
+ }
+
+ /* Remove the slash -- e.g. \+ --> + except before: ... */
+ switch (*s)
+ {
+ case '<': /* characters that form backslashed GNU */
+ case '>': /* extensions */
+ case '\'':
+ case '`':
+ case 'b':
+ case 'B':
+ case 'G':
+ case 's':
+ case 'S':
+ case 'w':
+ case 'W':
+
+ case '1': /* digits */
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ *d++ = '\\';
+ *d++ = *s++;
+ literal = 0;
+ break;
+
+ case '+':
+ case '{':
+ if (!literal && s != start)
+ {
+ if (s[-1] == '^' || s[-1] == '(')
+ /* Brace and plus are literals in ^\{, ^\+, (\{, (\+ */
+ literal = 1;
+ }
+ else
+ literal = 0;
+
+ *d++ = *s++;
+ break;
+
+ case '.': /* characters that are special in basic regexps too */
+ case '*':
+ case '[':
+ case '^':
+ case '$':
+
+ case 'a': /* characters that must be escaped in basic */
+ case 'f': /* regexps too based on GNU sed 3.02.80 */
+ case 'e':
+ case 'n':
+ case 'r':
+ case 't':
+ case 'v':
+ case 'd':
+ case 'o':
+ case 'x':
+ case '\n':
+ case '\\':
+ *d++ = '\\';
+
+ default:
+ *d++ = *s++;
+ literal = 1;
+ break;
+ }
+ break;
+
+ /* Skip character classes */
+ case '[':
+ literal = 1;
+ *d++ = *s++;
+ if (s < end && *s == '^')
+ *d++ = *s++;
+ if (s < end && *s == ']')
+ *d++ = *s++;
+ while (s < end && *s != ']')
+ *d++ = *s++;
+ if (s < end && *s == ']')
+ *d++ = *s++;
+ break;
+
+ case '^':
+ literal = 0;
+ *d++ = *s++;
+ break;
+
+ case '*':
+ if (!literal && s != start)
+ {
+ if (s[-1] == '^' || s[-1] == '(')
+ /* ^* and (* are a literal * */
+ literal = 1;
+ }
+ else
+ literal = 0;
+
+ *d++ = *s++;
+ break;
+
+ /* Add a slash if the character is special in extended regexps */
+ case '+':
+ case '?':
+ case '|':
+ case '(':
+ case ')':
+ case '{':
+ case '}':
+ *d++ = '\\';
+
+ /* Fall through */
+
+ default:
+ literal = 1;
+ *d++ = *s++;
+ }
+
+ *patlen = d - base;
+ return base;
+}
+
+void
+basic_regexp_erroroffset (s, offset)
+ const char *s;
+ int *offset;
+{
+ (pcre_free) (basic_to_extended_regexp (s, offset));
+}
+
+
+/*************************************************
+* Compile a Regular Expression *
+*************************************************/
+
+/* This function takes a string and returns a pointer to a block of store
+ holding a compiled version of the expression.
+
+ Arguments:
+ pattern the regular expression
+ options various option bits
+ errorptr pointer to pointer to error text
+ erroroffset ptr offset in pattern where error was detected
+ tables pointer to character tables or NULL
+
+ Returns: pointer to compiled data block, or NULL on error,
+ with errorptr and erroroffset set
+ */
+
+pcre *
+pcre_posix_compile (pattern, options, errorptr, erroroffset, tables)
+ const char *pattern;
+ int options;
+ const char **errorptr;
+ int *erroroffset;
+ const unsigned char *tables;
+{
+ return pcre_posix_compile_nuls (pattern, (int) strlen (pattern), options,
+ errorptr, erroroffset, tables);
+}
+
+pcre *
+pcre_posix_compile_nuls (pattern, patlen, options,
+ errorptr, erroroffset, tables)
+ const char *pattern;
+ int patlen;
+ int options;
+ const char **errorptr;
+ int *erroroffset;
+ const unsigned char *tables;
+{
+ pcre *re;
+ int length = 3; /* For initial BRA plus length */
+ int runlength;
+ int c, reqchar, countlits, prev;
+ int bracount = 0;
+ int top_backref = 0;
+ int branch_extra = 0;
+ int branch_newextra;
+ unsigned int brastackptr = 0;
+ size_t size;
+ uschar *code;
+ const uschar *ptr;
+ compile_data compile_block;
+ int brastack[BRASTACK_SIZE];
+ uschar bralenstack[BRASTACK_SIZE];
+ static const unsigned char *def_tables;
+
+#ifdef DEBUG
+ uschar *code_base, *code_end;
+#endif
+
+ /* We can't pass back an error message if errorptr is NULL; I guess the best we
+ can do is just return NULL. */
+ if (errorptr == NULL)
+ return NULL;
+ *errorptr = NULL;
+
+ /* However, we can give a message for this error */
+ if (erroroffset == NULL)
+ {
+ *errorptr = pcre_estrings[16];
+ return NULL;
+ }
+ *erroroffset = 0;
+
+ if ((options & ~PUBLIC_OPTIONS) != 0)
+ {
+ *errorptr = pcre_estrings[17];
+ return NULL;
+ }
+
+ /* Call ourselves recursively with an extended regular expression if we were
+ given a basic one. Extended regular expressions are similar to Perl's
+ than basic regular expression, so we share most of the code with regperl.c
+ if we work this way. */
+ if (!(options & PCRE_EXTENDED))
+ {
+ uschar *ere = basic_to_extended_regexp (pattern, &patlen);
+ re = pcre_posix_compile_nuls (ere, patlen, options | PCRE_EXTENDED,
+ errorptr, erroroffset, tables);
+
+ if (*errorptr != NULL)
+ basic_regexp_erroroffset (ere, erroroffset);
+ (pcre_free) (ere);
+ return re;
+ }
+
+ /* Set up pointers to the individual character tables */
+ if (!tables)
+ {
+ if (!def_tables)
+ def_tables = pcre_maketables ();
+ tables = def_tables;
+ }
+ compile_block.lcc = tables + lcc_offset;
+ compile_block.fcc = tables + fcc_offset;
+ compile_block.cbits = tables + cbits_offset;
+ compile_block.ctypes = tables + ctypes_offset;
+ compile_block.end = pattern + patlen - 1;
+ compile_block.max_match_size = 0;
+
+ /* Reflect pattern for debugging output */
+ DPRINTF (
+ ("------------------------------------------------------------------\n"));
+ DFWRITE ((pattern, 1, patlen, stdout));
+ DPRINTF (("\n"));
+
+ /* The first thing to do is to make a pass over the pattern to compute the
+ amount of store required to hold the compiled code. This does not have to be
+ perfect as long as errors are overestimates. At the same time we can detect any
+ internal flag settings. */
+ for (prev = -1, ptr = (const uschar *) pattern;
+ ptr <= compile_block.end;
+ prev = c, ptr++)
+ {
+ int min = 1, max = 1;
+ int class_charcount;
+ int bracket_length;
+
+ c = *ptr;
+ switch (c)
+ {
+ /* A backslashed item may be an escaped "normal" character or a
+ character type. For a "normal" character, put the pointers and
+ character back so that tests for whitespace etc. in the input
+ are done correctly. */
+
+ case '\\':
+ {
+ const uschar *save_ptr = ptr;
+ if (ptr == compile_block.end)
+ *errorptr = pcre_estrings[1];
+ else
+ c = check_escape (&ptr, errorptr, bracount, options,
+ FALSE, &compile_block);
+
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if (c >= 0)
+ {
+ ptr = save_ptr;
+ c = '\\';
+ goto NORMAL_CHAR;
+ }
+ }
+
+ /* A back reference needs an additional 2 bytes, plus either zero or 4
+ bytes for a repeat. We also need to keep the value of the highest
+ back reference. */
+
+ if (c <= -ESC_REF)
+ {
+ int refnum = -c - ESC_REF;
+ if (refnum > top_backref)
+ top_backref = refnum;
+ length += 3; /* For single back reference */
+ if (ptr < compile_block.end && ptr[1] == '{'
+ && is_counted_repeat (ptr + 2, &compile_block))
+ {
+ ptr =
+ read_repeat_counts (ptr + 2, &min, &max, errorptr,
+ &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if ((min == 0 && (max == 1 || max == -1)) ||
+ (min == 1 && max == -1))
+ ;
+ else
+ length += 4;
+ }
+ }
+ else if (c <= 0)
+ length += 2;
+ else
+ length++;
+ continue;
+
+ case '*': /* These repeats won't be after brackets; */
+ case '+': /* those are handled separately */
+ case '?':
+ if (prev == -1)
+ goto NORMAL_CHAR;
+
+ case '.':
+ length += (ptr != compile_block.end && *(ptr + 1) == '{') ? 2 : 1;
+ continue;
+
+ /* This covers the cases of repeats after a single char, metachar, class,
+ or back reference. */
+
+ case '{':
+ if (!is_counted_repeat (ptr + 1, &compile_block))
+ goto NORMAL_CHAR;
+ ptr =
+ read_repeat_counts (ptr + 1, &min, &max, errorptr,
+ &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if ((min == 0 && (max == 1 || max == -1)) ||
+ (min == 1 && max == -1))
+ length++;
+ else
+ {
+ length--; /* Uncount the original char or metachar */
+ if (min == 1)
+ length++;
+ else if (min > 0)
+ length += 4;
+ if (max > 0)
+ length += 4;
+ else
+ length += 2;
+ }
+ continue;
+
+ /* An alternation contains an offset to the next branch or ket. If any ims
+ options changed in the previous branch(es), extra space will be
+ needed at the start of the branch. This is handled by branch_extra. */
+
+ case '|':
+ length += 3 + branch_extra;
+ continue;
+
+ /* A character class uses 33 characters. Don't worry about character types
+ that aren't allowed in classes - they'll get picked up during the compile.
+ A character class that contains only one character uses 2 or 3 bytes,
+ depending on whether it is negated or not. Notice this where we can. */
+
+ case '[':
+ class_charcount = 0;
+ if (ptr < compile_block.end && *(++ptr) == '^')
+ ptr++;
+
+ if (ptr <= compile_block.end)
+ do
+ {
+ if (*ptr == '\\')
+ {
+ if (ptr == compile_block.end)
+ {
+ /* Lone backslash, signal an error */
+ *errorptr = pcre_estrings[1];
+ goto PCRE_ERROR_RETURN;
+ }
+ else
+ {
+ int i;
+
+ /* Inside a class, literal escapes are interpreted as a
+ separate backslash followed by another character. */
+ c = ptr[1];
+ if (c >= ' ' && c <= 'z' &&
+ (i == escapes[c - ' '] > 0) && i != c)
+ {
+ class_charcount++;
+ ptr++;
+ }
+ }
+ }
+
+ class_charcount++;
+ ptr++;
+ }
+ while (ptr <= compile_block.end && *ptr != ']');
+
+ /* Repeats for negated single chars are handled by the general code */
+
+ if (class_charcount == 1)
+ length += 3;
+ else
+ {
+ length += 33;
+
+ /* A repeat needs either 0 or 4 bytes. */
+
+ if (ptr < compile_block.end && ptr[1] == '{'
+ && is_counted_repeat (ptr + 2, &compile_block))
+ {
+ ptr =
+ read_repeat_counts (ptr + 2, &min, &max, errorptr,
+ &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if ((min == 0 && (max == 1 || max == -1)) ||
+ (min == 1 && max == -1))
+ ;
+ else
+ length += 4;
+ }
+ }
+ continue;
+
+ /* Brackets may be genuine groups or special things */
+
+ case '(':
+ branch_newextra = 0;
+ bracket_length = 3;
+
+ /* Capturing brackets must be counted so we can process escapes in a
+ Perlish way. */
+
+ bracount++;
+ if (bracount > EXTRACT_BASIC_MAX)
+ bracket_length += 3;
+
+ /* Save length for computing whole length at end if there's a repeat that
+ requires duplication of the group. Also save the current value of
+ branch_extra, and start the new group with the new value. If non-zero, this
+ will either be 2 for a (?imsx: group, or 3 for a lookbehind assertion. */
+
+ if (brastackptr >= sizeof (brastack) / sizeof (int))
+ {
+ *errorptr = pcre_estrings[19];
+ goto PCRE_ERROR_RETURN;
+ }
+
+ bralenstack[brastackptr] = branch_extra;
+ branch_extra = branch_newextra;
+
+ brastack[brastackptr++] = length;
+ length += bracket_length;
+
+ /* Treat a *+? after a ( as a literal char */
+ c = -1;
+ continue;
+
+ /* Handle ket. Look for subsequent max/min; for certain sets of values we
+ have to replicate this bracket up to that many times. If brastackptr is
+ 0 this is an unmatched bracket which will generate an error, but take care
+ not to try to access brastack[-1] when computing the length and restoring
+ the branch_extra value. */
+
+ case ')':
+ length += 3;
+ {
+ int minval = 1;
+ int maxval = 1;
+ int duplength;
+
+ if (brastackptr > 0)
+ {
+ duplength = length - brastack[--brastackptr];
+ branch_extra = bralenstack[brastackptr];
+ }
+ else
+ duplength = 0;
+
+ /* Leave ptr at the final char; for read_repeat_counts this happens
+ automatically; for the others we need an increment. */
+
+ if (ptr == compile_block.end)
+ {
+ }
+ else if ((c = ptr[1]) == '{' &&
+ is_counted_repeat (ptr + 2, &compile_block))
+ {
+ ptr =
+ read_repeat_counts (ptr + 2, &minval, &maxval, errorptr,
+ &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ }
+ else if (c == '*')
+ {
+ minval = 0;
+ maxval = -1;
+ ptr++;
+ }
+ else if (c == '+')
+ {
+ maxval = -1;
+ ptr++;
+ }
+ else if (c == '?')
+ {
+ minval = 0;
+ ptr++;
+ }
+
+ /* If the minimum is zero, we have to allow for an OP_BRAZERO before the
+ group, and if the maximum is greater than zero, we have to replicate
+ maxval-1 times; each replication acquires an OP_BRAZERO plus a nesting
+ bracket set - hence the 7. */
+
+ if (minval == 0)
+ {
+ length++;
+ if (maxval > 0)
+ length += (maxval - 1) * (duplength + 7);
+ }
+
+ /* When the minimum is greater than zero, 1 we have to replicate up to
+ minval-1 times, with no additions required in the copies. Then, if
+ there is a limited maximum we have to replicate up to maxval-1 times
+ allowing for a BRAZERO item before each optional copy and nesting
+ brackets for all but one of the optional copies. */
+
+ else
+ {
+ length += (minval - 1) * duplength;
+ if (maxval > minval) /* Need this test as maxval=-1 means no limit */
+ length += (maxval - minval) * (duplength + 7) - 6;
+ }
+ }
+ continue;
+
+ /* Non-special character. For a run of such characters the length required
+ is the number of characters + 2, except that the maximum run length is 255.
+ We won't get a skipped space or a non-data escape or the start of a #
+ comment as the first character, so the length can't be zero.
+ We put carets and dollars here because they can be either metacharacters
+ or literal characters; determining which they are is indeed possible
+ but an extra chore -- so we always count them as literal characters
+ (which take more space than metacharacters). */
+
+ case '^':
+ case '$':
+ NORMAL_CHAR:
+ default:
+ length += 2;
+ runlength = 0;
+ do
+ {
+ /* Backslash may introduce a data char or a metacharacter; stop the
+ string before the latter. */
+
+ if (c == '\\')
+ {
+ const uschar *saveptr = ptr;
+ c =
+ check_escape (&ptr, errorptr, bracount, options, FALSE,
+ &compile_block);
+ if (*errorptr != NULL)
+ goto PCRE_ERROR_RETURN;
+ if (c < 0)
+ {
+ ptr = saveptr - 1;
+ c = '\\';
+ break;
+ }
+ }
+
+ /* Ordinary character or single-char escape */
+
+ runlength++;
+ c = 0;
+ }
+ /* This "while" is the end of the "do" above. */
+
+ while (runlength < MAXLIT && ptr <= compile_block.end &&
+ (compile_block.ctypes[c = *(++ptr)] & ctype_meta) == 0);
+
+ if (compile_block.ctypes[c] & ctype_meta)
+ ptr--;
+ length += runlength;
+ continue;
+ }
+ }
+
+ length += 4; /* For final KET and END */
+
+ if (length > 65539)
+ {
+ *errorptr = pcre_estrings[20];
+ return NULL;
+ }
+
+ /* Compute the size of data block needed and get it, either from malloc or
+ externally provided function. We specify "code[0]" in the offsetof() expression
+ rather than just "code", because it has been reported that one broken compiler
+ fails on "code" because it is also an independent variable. It should make no
+ difference to the value of the offsetof(). */
+ size = length + offsetof (pcre, code[0]);
+ re = (pcre *) (pcre_malloc) (size);
+
+ if (re == NULL)
+ {
+ *errorptr = pcre_estrings[21];
+ return NULL;
+ }
+
+ /* Put in the magic number, and save the size, options, and table pointer */
+ re->magic_number = MAGIC_NUMBER;
+ re->size = size;
+ re->options = options;
+ re->tables = tables;
+
+ /* Set up a starting, non-capturing bracket, then compile the expression. On
+ error, *errorptr will be set non-NULL, so we don't need to look at the result
+ of the function here. */
+ ptr = (const uschar *) pattern;
+ code = re->code;
+ *code = OP_BRA;
+ bracount = 0;
+ (void) compile_regex (options, -1, &bracount, &code, &ptr, errorptr, FALSE,
+ 0, &reqchar, &countlits, &compile_block, compile_branch_posix);
+ re->top_bracket = bracount;
+ re->top_backref = top_backref;
+
+ /* If not reached end of pattern on success, there's an excess bracket. */
+ if (*errorptr == NULL && ptr <= compile_block.end)
+ *errorptr = pcre_estrings[22];
+
+ /* Fill in the terminating state and check for disastrous overflow, but
+ if debugging, leave the test till after things are printed out. */
+ *code++ = OP_END;
+
+#ifndef DEBUG
+ if (code - re->code > length)
+ *errorptr = pcre_estrings[23];
+#endif
+
+ /* Give an error if there's back reference to a non-existent capturing
+ subpattern. */
+ if (top_backref > re->top_bracket)
+ *errorptr = pcre_estrings[15];
+
+ /* Failed to compile */
+ if (*errorptr != NULL)
+ {
+ (pcre_free) (re);
+ PCRE_ERROR_RETURN:
+ *erroroffset = ptr - (const uschar *) pattern;
+ return NULL;
+ }
+
+ /* If the anchored option was not passed, set flag if we can determine that the
+ pattern is anchored by virtue of ^ characters or \A or anything else (such as
+ starting with .* when DOTALL is set).
+
+ Otherwise, see if we can determine what the first character has to be, because
+ that speeds up unanchored matches no end. If not, see if we can set the
+ PCRE_STARTLINE flag. This is helpful for multiline matches when all branches
+ start with ^. and also when all branches start with .* for non-DOTALL matches. */
+ if ((options & PCRE_ANCHORED) == 0)
+ {
+ int temp_options = options;
+ if (is_anchored (re->code, &temp_options))
+ re->options |= PCRE_ANCHORED;
+ else
+ {
+ int ch = find_firstchar (re->code, &temp_options);
+ if (ch >= 0)
+ {
+ re->first_char = ch;
+ re->options |= PCRE_FIRSTSET;
+ }
+ else if (is_startline (re->code))
+ re->options |= PCRE_STARTLINE;
+ }
+ }
+
+ /* If we cannot determine the maximum match size or it is useless,
+ set the field to -1 */
+ if (compile_block.max_match_size < 0 || !is_endline(re->code))
+ re->max_match_size = -1;
+ else
+ re->max_match_size = compile_block.max_match_size;
+
+ /* Save the last required character if there are at least two literal
+ characters on all paths, or if there is no first character setting. */
+ if (reqchar >= 0 && (countlits > 1 || (re->options & PCRE_FIRSTSET) == 0))
+ {
+ re->req_char = reqchar;
+ re->options |= PCRE_REQCHSET;
+ }
+
+ /* Print out the compiled data for debugging */
+#ifdef DEBUG
+ pcre_debug (re);
+
+ if (code - re->code > length)
+ {
+ *errorptr = pcre_estrings[23];
+ (pcre_free) (re);
+ *erroroffset = ptr - (uschar *) pattern;
+ return NULL;
+ }
+#endif
+
+ if (*errorptr && (options & PCRE_ENGLISH_ERRORS) == 0)
+ *errorptr = gettext (*errorptr);
+
+ return (pcre *) re;
+}
diff --git a/pcre/regstudy.c b/pcre/regstudy.c
new file mode 100644
index 0000000..8d6f1b8
--- /dev/null
+++ b/pcre/regstudy.c
@@ -0,0 +1,1352 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+
+/* Include the internals header, which itself includes Standard C headers plus
+ the external pcre header. */
+
+#include "internal.h"
+
+uschar pruned[] = {
+ OP_END,
+
+ OP_BEG_WORD, OP_END_WORD, OP_ANCHOR_MATCH,
+ OP_NOT_WORD_BOUNDARY, OP_WORD_BOUNDARY,
+ OP_SOD, OP_EODN, OP_EOD,
+ OP_OPT, OP_CIRC, OP_DOLL, OP_ANY,
+
+ OP_CHARS,
+ OP_ONCESTAR, OP_ONCESTAR, OP_ONCESTAR,
+ OP_ONCEPLUS, OP_ONCEPLUS, OP_ONCEPLUS,
+ OP_ONCEQUERY, OP_ONCEQUERY, OP_ONCEQUERY,
+ OP_ONCEUPTO, OP_ONCEUPTO, OP_ONCEUPTO,
+ OP_EXACT,
+
+ OP_NOT,
+ OP_NOT_ONCESTAR, OP_NOT_ONCESTAR, OP_NOT_ONCESTAR,
+ OP_NOT_ONCEPLUS, OP_NOT_ONCEPLUS, OP_NOT_ONCEPLUS,
+ OP_NOT_ONCEQUERY, OP_NOT_ONCEQUERY, OP_NOT_ONCEQUERY,
+ OP_NOT_ONCEUPTO, OP_NOT_ONCEUPTO, OP_NOT_ONCEUPTO,
+ OP_NOTEXACT,
+
+ OP_TYPE,
+ OP_TYPE_ONCESTAR, OP_TYPE_ONCESTAR, OP_TYPE_ONCESTAR,
+ OP_TYPE_ONCEPLUS, OP_TYPE_ONCEPLUS, OP_TYPE_ONCEPLUS,
+ OP_TYPE_ONCEQUERY, OP_TYPE_ONCEQUERY, OP_TYPE_ONCEQUERY,
+ OP_TYPE_ONCEUPTO, OP_TYPE_ONCEUPTO, OP_TYPE_ONCEUPTO,
+ OP_TYPEEXACT,
+
+ OP_TYPENOT,
+ OP_TYPENOT_ONCESTAR, OP_TYPENOT_ONCESTAR, OP_TYPENOT_ONCESTAR,
+ OP_TYPENOT_ONCEPLUS, OP_TYPENOT_ONCEPLUS, OP_TYPENOT_ONCEPLUS,
+ OP_TYPENOT_ONCEQUERY, OP_TYPENOT_ONCEQUERY, OP_TYPENOT_ONCEQUERY,
+ OP_TYPENOT_ONCEUPTO, OP_TYPENOT_ONCEUPTO, OP_TYPENOT_ONCEUPTO,
+ OP_TYPENOTEXACT,
+
+ OP_CLASS,
+ OP_CL_ONCESTAR, OP_CL_ONCESTAR, OP_CL_ONCESTAR,
+ OP_CL_ONCEPLUS, OP_CL_ONCEPLUS, OP_CL_ONCEPLUS,
+ OP_CL_ONCEQUERY, OP_CL_ONCEQUERY, OP_CL_ONCEQUERY,
+ OP_CL_ONCERANGE, OP_CL_ONCERANGE, OP_CL_ONCERANGE,
+
+ OP_REF,
+ OP_REF_ONCESTAR, OP_REF_ONCESTAR, OP_REF_ONCESTAR,
+ OP_REF_ONCEPLUS, OP_REF_ONCEPLUS, OP_REF_ONCEPLUS,
+ OP_REF_ONCEQUERY, OP_REF_ONCEQUERY, OP_REF_ONCEQUERY,
+ OP_REF_ONCERANGE, OP_REF_ONCERANGE, OP_REF_ONCERANGE,
+
+ OP_RECURSE, OP_ALT, OP_KET,
+
+ OP_KET_ONCESTAR, OP_KET_ONCESTAR, OP_KET_ONCESTAR,
+
+ OP_ASSERT, OP_ASSERT_NOT,
+ OP_ASSERTBACK, OP_ASSERTBACK_NOT,
+ OP_REVERSE, OP_ONCE,
+ OP_COND, OP_CREF,
+ OP_BRAZERO, OP_BRAMINZERO,
+ OP_BRANUMBER
+};
+
+
+/*************************************************
+* Set an entry and maybe its alternate case *
+*************************************************/
+
+/* Given a character, set its bit in the table, and also the bit for the other
+ version of a letter if we are caseless.
+
+ Arguments:
+ bmtable points to the Boyer-Moore table
+ c is the character
+ length the value of the entry.
+ caseless the caseless flag
+ cd the block with char table pointers
+
+ Returns: nothing
+ */
+
+static void
+set_bmtable (bmtable, c, length, caseless, cd)
+ uschar *bmtable;
+ int c;
+ int length;
+ BOOL caseless;
+ compile_data *cd;
+{
+ bmtable[c] = length;
+ if (caseless && (cd->ctypes[c] & ctype_letter) != 0)
+ {
+ bmtable[cd->fcc[c]] = length;
+ }
+}
+
+
+
+
+/*************************************************
+* Set a bit and maybe its alternate case *
+*************************************************/
+
+/* Given a character, set its bit in the table, and also the bit for the other
+ version of a letter if we are caseless.
+
+ Arguments:
+ bmtable points to the bit map
+ c is the character
+ caseless the caseless flag
+ cd the block with char table pointers
+
+ Returns: nothing
+ */
+
+static void
+set_bit (start_bits, c, caseless, cd)
+ uschar *start_bits;
+ int c;
+ BOOL caseless;
+ compile_data *cd;
+{
+ start_bits[c / 8] |= (1 << (c & 7));
+ if (caseless && (cd->ctypes[c] & ctype_letter) != 0)
+ start_bits[cd->fcc[c] / 8] |= (1 << (cd->fcc[c] & 7));
+}
+
+
+
+/*************************************************
+* Create map of starting string *
+*************************************************/
+
+/* This function scans a compiled unanchored expression and attempts to build a
+ map of the characters occurring in an initial fixed-length string. It
+ returns the length of the string it finds.
+
+ Arguments:
+ code points to an expression
+ bmtable points to a 256-byte table, initialized to 0
+ length base value to be given to the table
+ caseless the current state of the caseless flag
+ cd the block with char table pointers
+
+ Returns: TRUE if table built, FALSE otherwise
+ */
+
+static int
+set_boyer_moore (code, bmtable, length, caseless, cd)
+ const uschar *code;
+ uschar *bmtable;
+ int length;
+ BOOL caseless;
+ compile_data *cd;
+{
+ const uschar *tcode = code + 3;
+ BOOL try_next = TRUE;
+ int old_length;
+
+ /* If the branch has more than one alternative, it's too
+ complicated, so exit. */
+ if (code[(code[1] << 8) + code[2]] == OP_ALT)
+ return length;
+
+ while (try_next && length < 255)
+ {
+ register int c = *tcode;
+ old_length = length;
+
+ NEXT_OPCODE:
+
+ switch (c)
+ {
+ /* Skip over extended extraction bracket number */
+
+ case OP_BRANUMBER:
+ tcode += 3;
+ break;
+
+
+ /* Skip over lookbehind assertions */
+
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ do
+ tcode += (tcode[1] << 8) + tcode[2];
+ while (*tcode == OP_ALT);
+ tcode += 3;
+ break;
+
+ /* Skip over an option setting, changing the caseless flag */
+
+ case OP_OPT:
+ caseless = (tcode[1] & PCRE_CASELESS) != 0;
+ tcode += 2;
+ break;
+
+ /* BRAZERO does the bracket, but carries on. */
+
+ case OP_BRAZERO:
+ case OP_BRAMINZERO:
+ try_next = FALSE;
+ break;
+
+ /* Single-char * ? upto stops the search */
+
+ case OP_MAXPLUS:
+ case OP_MINPLUS:
+ case OP_ONCEPLUS:
+ set_bmtable (bmtable, tcode[1], ++length, caseless, cd);
+
+ case OP_MAXSTAR:
+ case OP_MINSTAR:
+ case OP_ONCESTAR:
+ case OP_MAXQUERY:
+ case OP_MINQUERY:
+ case OP_ONCEQUERY:
+ case OP_MAXUPTO:
+ case OP_MINUPTO:
+ case OP_ONCEUPTO:
+ try_next = FALSE;
+ break;
+
+ /* At least one single char sets the bit and stops */
+
+ case OP_EXACT:
+ length += (tcode[1] << 8) + tcode[2];
+ set_bmtable (bmtable, tcode[3], length, caseless, cd);
+ tcode += 4;
+ break;
+
+ case OP_CHARS:
+ {
+ register int nchars = tcode[1];
+ if (nchars > 255 - length)
+ nchars = 255 - length;
+
+ tcode += 2;
+ while (nchars--)
+ set_bmtable (bmtable, *tcode++, ++length, caseless, cd);
+ }
+ break;
+
+ /* Single character type sets the bits and stops */
+
+ case OP_TYPENOT:
+ tcode++;
+ REPEATTYPENOT:
+ length++;
+ for (c = 0; c < 255; c++)
+ if (!*tcode || !(cd->ctypes[c] & (1 << *tcode)))
+ set_bmtable (bmtable, c, length, caseless, cd);
+
+ break;
+
+ case OP_TYPE:
+ tcode++;
+ REPEATTYPE:
+ length++;
+ for (c = 0; c < 255; c++)
+ if (cd->ctypes[c] & (*tcode ? 1 << *tcode : 0))
+ set_bmtable (bmtable, c, length, caseless, cd);
+
+ break;
+
+ /* One or more character type fudges the pointer and restarts, knowing
+ it will hit a single character. */
+
+ case OP_TYPE_MAXPLUS:
+ case OP_TYPE_MINPLUS:
+ case OP_TYPE_ONCEPLUS:
+ tcode++;
+ try_next = FALSE;
+ goto REPEATTYPE;
+
+ case OP_TYPEEXACT:
+ tcode += 3;
+ length += (tcode[1] << 8) + tcode[2] - 1;
+ if (length > 255)
+ length = 255;
+ goto REPEATTYPE;
+
+ case OP_TYPENOT_MAXPLUS:
+ case OP_TYPENOT_MINPLUS:
+ case OP_TYPENOT_ONCEPLUS:
+ tcode++;
+ try_next = FALSE;
+ goto REPEATTYPENOT;
+
+ case OP_TYPENOTEXACT:
+ tcode += 3;
+ length += (tcode[1] << 8) + tcode[2] - 1;
+ if (length > 255)
+ length = 255;
+ goto REPEATTYPENOT;
+
+ /* Zero or more repeats of character types stop here. */
+
+ case OP_TYPE_MAXUPTO:
+ case OP_TYPE_MINUPTO:
+ case OP_TYPE_ONCEUPTO:
+ case OP_TYPE_MAXSTAR:
+ case OP_TYPE_MINSTAR:
+ case OP_TYPE_ONCESTAR:
+ case OP_TYPE_MAXQUERY:
+ case OP_TYPE_MINQUERY:
+ case OP_TYPE_ONCEQUERY:
+ case OP_TYPENOT_MAXUPTO:
+ case OP_TYPENOT_MINUPTO:
+ case OP_TYPENOT_ONCEUPTO:
+ case OP_TYPENOT_MAXSTAR:
+ case OP_TYPENOT_MINSTAR:
+ case OP_TYPENOT_ONCESTAR:
+ case OP_TYPENOT_MAXQUERY:
+ case OP_TYPENOT_MINQUERY:
+ case OP_TYPENOT_ONCEQUERY:
+ try_next = FALSE;
+ break;
+
+ /* Character class: set the bits and either carry on or not,
+ according to the repeat count. */
+
+ case OP_CLASS:
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ case OP_CL_ONCERANGE:
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_ONCESTAR:
+ case OP_CL_MAXPLUS:
+ case OP_CL_MINPLUS:
+ case OP_CL_ONCEPLUS:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CL_ONCEQUERY:
+ {
+ register const uschar *classptr = tcode + 1;
+ tcode++;
+ switch (tcode[-1])
+ {
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_ONCESTAR:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CL_ONCEQUERY:
+ try_next = FALSE;
+ break;
+
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ case OP_CL_ONCERANGE:
+ try_next = FALSE;
+ if (((tcode[0] << 8) + tcode[1]) == 0)
+ break;
+
+ /* There is a minimum length, fall through */
+ length += (tcode[0] << 8) + tcode[1] - 1;
+ if (length > 255)
+ length = 255;
+
+ tcode += 4;
+
+ case OP_CL_MAXPLUS:
+ case OP_CL_MINPLUS:
+ case OP_CL_ONCEPLUS:
+ try_next = FALSE;
+
+ default:
+ length++;
+ for (c = 0; c < 255; c++)
+ if (classptr[c >> 3] & (1 << (c & 7)))
+ set_bmtable (bmtable, c, length, caseless, cd);
+ break;
+ }
+
+ tcode += 32;
+ break; /* End of class handling */
+ }
+
+ default:
+ /* Undo the effect of a OP_TYPE... opcode */
+ length = old_length;
+
+ /* If a branch starts with a bracket, recurse to set the string
+ from within them. That's all for this branch. */
+
+ if ((int) *tcode >= OP_BRA)
+ length = set_boyer_moore (tcode, bmtable,
+ length, caseless, cd);
+ try_next = FALSE;
+ break;
+ } /* End of switch */
+ } /* End of try_next loop */
+
+ return length;
+}
+
+
+/*************************************************
+* Create map of starting chars *
+*************************************************/
+
+/* This function scans a compiled unanchored expression and attempts to build a
+ map of the characters occurring at the start of the match. If it can't, it
+ returns FALSE. As time goes by, we may be able to get more clever at doing
+ this.
+
+ Arguments:
+ code points to an expression
+ start_bits points to a 32-byte table, initialized to 0
+ caseless the current state of the caseless flag
+ cd the block with char table pointers
+
+ Returns: TRUE if table built, FALSE otherwise
+ */
+
+
+static BOOL
+set_start_bits (code, start_bits, caseless, cd)
+ const uschar *code;
+ uschar *start_bits;
+ BOOL caseless;
+ compile_data *cd;
+{
+ register int c;
+
+ /* This next statement and the later reference to dummy are here in order to
+ trick the optimizer of the IBM C compiler for OS/2 into generating correct
+ code. Apparently IBM isn't going to fix the problem, and we would rather not
+ disable optimization (in this module it actually makes a big difference, and
+ the pcre module can use all the optimization it can get). */
+
+ volatile int dummy;
+
+ do
+ {
+ const uschar *tcode = code + 3;
+ BOOL try_next = TRUE;
+
+ while (try_next)
+ {
+ /* If a branch starts with a bracket or a positive lookahead assertion,
+ recurse to set bits from within them. That's all for this branch. */
+
+ if ((int) *tcode >= OP_BRA || *tcode == OP_ASSERT)
+ {
+ if (!set_start_bits (tcode, start_bits, caseless, cd))
+ return FALSE;
+ try_next = FALSE;
+ }
+
+ else
+ switch (*tcode)
+ {
+ default:
+ return FALSE;
+
+ /* Skip over extended extraction bracket number */
+
+ case OP_BRANUMBER:
+ tcode += 3;
+ break;
+
+ /* Skip over lookbehind and negative lookahead assertions */
+
+ case OP_ASSERT_NOT:
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ do
+ tcode += (tcode[1] << 8) + tcode[2];
+ while (*tcode == OP_ALT);
+ tcode += 3;
+ break;
+
+ /* Skip over an option setting, changing the caseless flag */
+
+ case OP_OPT:
+ caseless = (tcode[1] & PCRE_CASELESS) != 0;
+ tcode += 2;
+ break;
+
+ /* BRAZERO does the bracket, but carries on. */
+
+ case OP_BRAZERO:
+ case OP_BRAMINZERO:
+ if (!set_start_bits (++tcode, start_bits, caseless, cd))
+ return FALSE;
+ dummy = 1;
+ do
+ tcode += (tcode[1] << 8) + tcode[2];
+ while (*tcode == OP_ALT);
+ tcode += 3;
+ break;
+
+ /* Single-char * or ? sets the bit and tries the next item */
+
+ case OP_MAXSTAR:
+ case OP_MINSTAR:
+ case OP_ONCESTAR:
+ case OP_MAXQUERY:
+ case OP_MINQUERY:
+ case OP_ONCEQUERY:
+ set_bit (start_bits, tcode[1], caseless, cd);
+ tcode += 2;
+ break;
+
+ /* Single-char upto sets the bit and tries the next */
+
+ case OP_MAXUPTO:
+ case OP_MINUPTO:
+ case OP_ONCEUPTO:
+ set_bit (start_bits, tcode[3], caseless, cd);
+ tcode += 4;
+ break;
+
+ /* At least one single char sets the bit and stops */
+
+ case OP_EXACT: /* Fall through */
+ tcode++;
+
+ case OP_CHARS: /* Fall through */
+ tcode++;
+
+ case OP_MAXPLUS:
+ case OP_MINPLUS:
+ case OP_ONCEPLUS:
+ set_bit (start_bits, tcode[1], caseless, cd);
+ try_next = FALSE;
+ break;
+
+ /* Single character type sets the bits and stops */
+
+ case OP_TYPENOT:
+ tcode++;
+ try_next = FALSE;
+ REPEATTYPENOT:
+ if (!*tcode)
+ return FALSE;
+
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= ~cd->cbits[c + *tcode * 32];
+ break;
+
+ case OP_TYPE:
+ tcode++;
+ try_next = FALSE;
+ REPEATTYPE:
+ if (!*tcode)
+ return FALSE;
+
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= cd->cbits[c + *tcode * 32];
+ break;
+
+ /* One or more character type fudges the pointer and restarts. */
+
+ case OP_TYPEEXACT:
+ tcode += 2;
+
+ case OP_TYPE_MAXPLUS:
+ case OP_TYPE_MINPLUS:
+ case OP_TYPE_ONCEPLUS:
+ tcode++;
+ try_next = FALSE;
+ goto REPEATTYPE;
+
+ /* Zero or more repeats of character types set the bits and then
+ try again. */
+
+ case OP_TYPE_MAXUPTO:
+ case OP_TYPE_MINUPTO:
+ case OP_TYPE_ONCEUPTO:
+ tcode += 2; /* Fall through */
+
+ case OP_TYPE_MAXSTAR:
+ case OP_TYPE_MINSTAR:
+ case OP_TYPE_ONCESTAR:
+ case OP_TYPE_MAXQUERY:
+ case OP_TYPE_MINQUERY:
+ case OP_TYPE_ONCEQUERY:
+ tcode++;
+ goto REPEATTYPE;
+ break;
+
+ /* One or more character type fudges the pointer and restarts. */
+
+ case OP_TYPENOTEXACT:
+ tcode += 2; /* Fall through */
+
+ case OP_TYPENOT_MAXPLUS:
+ case OP_TYPENOT_MINPLUS:
+ case OP_TYPENOT_ONCEPLUS:
+ try_next = FALSE;
+ goto REPEATTYPENOT;
+
+ case OP_TYPENOT_MAXUPTO:
+ case OP_TYPENOT_MINUPTO:
+ case OP_TYPENOT_ONCEUPTO:
+ tcode += 2; /* Fall through */
+
+ case OP_TYPENOT_MAXSTAR:
+ case OP_TYPENOT_MINSTAR:
+ case OP_TYPENOT_ONCESTAR:
+ case OP_TYPENOT_MAXQUERY:
+ case OP_TYPENOT_MINQUERY:
+ case OP_TYPENOT_ONCEQUERY:
+ tcode++;
+ goto REPEATTYPENOT;
+
+ /* Character class: set the bits and either carry on or not,
+ according to the repeat count. */
+
+ case OP_CLASS:
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_ONCESTAR:
+ case OP_CL_MAXPLUS:
+ case OP_CL_MINPLUS:
+ case OP_CL_ONCEPLUS:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CL_ONCEQUERY:
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ case OP_CL_ONCERANGE:
+ {
+ tcode++;
+ for (c = 0; c < 32; c++)
+ start_bits[c] |= tcode[c];
+ tcode += 32;
+ switch (tcode[-33])
+ {
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_ONCESTAR:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CL_ONCEQUERY:
+ break;
+
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ case OP_CL_ONCERANGE:
+ if (((tcode[1] << 8) + tcode[2]) == 0)
+ tcode += 4;
+ else
+ try_next = FALSE;
+ break;
+ }
+ }
+ break; /* End of class handling */
+
+ } /* End of switch */
+ } /* End of try_next loop */
+
+ code += (code[1] << 8) + code[2]; /* Advance to next branch */
+ }
+ while (*code == OP_ALT);
+ return TRUE;
+}
+
+
+
+/*************************************************
+* Prune paths from a bracket *
+*************************************************/
+
+/* This function is handed a pointer to the opcodes for a bracket in
+ which it must prune impossible backtracking paths. This is done
+ by replacing _MAX* and _MIN* opcodes by the corresponding _ONCE*
+ opcodes.
+
+ Arguments:
+ codeptr points to the first opcode we're interested in,
+ on output it is rewritten with the end of the bracket
+ bracket_start points to an array of bitsets that contain
+ the possible starting characters of the capturing
+ subpatterns
+ bracket_end points to an array of bitsets that contain
+ the possible ending characters of the capturing
+ subpatterns
+ caseless the caseless flag
+ cd the block with char table pointers
+ end points to where the function will store the character
+ class for the end
+ */
+
+BOOL
+prune_bracket (prevptr, codeptr, bracket_start,
+ bracket_end, caseless, cd, end)
+ uschar **prevptr, **codeptr;
+ BOOL caseless;
+ bitset *bracket_start, *bracket_end;
+ compile_data *cd;
+ bitset end;
+{
+ bitset prev_class, curr_class, start;
+ uschar *previous = NULL, *current, *code = *codeptr;
+ int backref;
+ BOOL is_final_opcode = FALSE;
+ BOOL found_start = FALSE;
+ BOOL had_alt = FALSE;
+ BOOL can_be_empty;
+
+ /* For extended extraction brackets (large number), we have to fish out the
+ number from a dummy opcode at the start. */
+
+ if (*code < OP_BRA)
+ {
+ backref = 0;
+
+ /* Skip over the assertion at the beginning of a conditional */
+ if (*code == OP_COND && code[3] == OP_ASSERT)
+ code += (code[4] << 8) | code[5];
+ }
+ else
+ {
+ backref = *code - OP_BRA;
+ if (backref > EXTRACT_BASIC_MAX)
+ backref = (code[4] << 8) | code[5];
+ }
+
+ code += 3;
+ current = code;
+ memset (curr_class, 0, 32);
+ memset (end, ~0, 32);
+
+ for (;;)
+ {
+ int i, c;
+ /* Undefining CONSERVATIVE seems to work, and optimizes cases like
+ b*c*b+ by leaving b* as is but pruning the c* backtracking path. */
+
+#ifdef CONSERVATIVE
+ memcpy (prev_class, end, 32);
+#else
+ memcpy (prev_class, curr_class, 32);
+#endif
+ memset (curr_class, 0, 32);
+ can_be_empty = TRUE;
+
+ switch (*code)
+ {
+ /* Skip over informational opcodes */
+
+ case OP_REVERSE:
+ case OP_CREF:
+ case OP_BRANUMBER:
+ code += 3;
+ break;
+
+ case OP_END:
+ case OP_KET:
+ case OP_KET_MINSTAR:
+ case OP_KET_MAXSTAR:
+ case OP_KET_ONCESTAR:
+ code += 3;
+ can_be_empty = FALSE;
+ is_final_opcode = TRUE;
+ memcpy (curr_class, prev_class, 32);
+
+ if (backref > 0)
+ {
+ if (found_start)
+ memcpy (&bracket_start[backref], start, 32);
+ else
+ memset (&bracket_start[backref], ~0, 32);
+ if (had_alt)
+ memset (&bracket_end[backref], ~0, 32);
+ else
+ memcpy (&bracket_end[backref], end, 32);
+ }
+ break;
+
+ case OP_ALT:
+ code += 3;
+ had_alt = TRUE;
+ found_start = FALSE;
+ can_be_empty = FALSE;
+ memset (curr_class, ~0, 32);
+ break;
+
+ /* Skip over things that don't match chars */
+
+ case OP_DOLL:
+ case OP_EODN:
+ memset (curr_class, ~0, 32);
+ curr_class[13 / 8] ^= 1 << (13 % 8);
+
+ case OP_ANCHOR_MATCH:
+ case OP_SOD:
+ case OP_CIRC:
+ case OP_EOD:
+ code++;
+ break;
+
+ case OP_NOT_WORD_BOUNDARY:
+ case OP_WORD_BOUNDARY:
+ memset (curr_class, ~0, 32);
+ code++;
+ break;
+
+ case OP_BEG_WORD:
+ for (c = 0; c < 32; c++)
+ curr_class[c] = cd->cbits[c + cbit_word];
+ code++;
+ break;
+
+ case OP_END_WORD:
+ for (c = 0; c < 32; c++)
+ curr_class[c] = ~cd->cbits[c + cbit_word];
+ code++;
+ break;
+
+ /* Skip over lookbehind and negative lookahead assertions */
+
+ case OP_ASSERTBACK:
+ case OP_ASSERTBACK_NOT:
+ do
+ code += (code[1] << 8) + code[2];
+ while (*code == OP_ALT);
+ memset (curr_class, ~0, 32);
+ code += 3;
+ break;
+
+ case OP_ASSERT:
+ prune_bracket (¤t, &code, bracket_start, bracket_end,
+ caseless, cd, &curr_class);
+ break;
+
+ case OP_ASSERT_NOT:
+ do
+ code += (code[1] << 8) + code[2];
+ while (*code == OP_ALT);
+ code += 3;
+ memset (curr_class, ~0, 32);
+ break;
+
+ /* Skip over an option setting, changing the caseless flag */
+
+ case OP_OPT:
+ caseless = (code[1] & PCRE_CASELESS) != 0;
+ /* FIXME m and s too */
+ code += 2;
+ break;
+
+ /* BRAZERO does the bracket, but carries on. */
+
+ case OP_BRAZERO:
+ case OP_BRAMINZERO:
+ code++;
+ prune_bracket (¤t, &code, bracket_start, bracket_end,
+ caseless, cd, &curr_class);
+ break;
+
+ /* Single character type sets the bits and stops */
+
+ case OP_TYPENOT:
+ code++;
+ can_be_empty = FALSE;
+ REPEATTYPENOT:
+ if (!*code)
+ memset (curr_class, ~0, 32);
+ else
+ for (c = 0; c < 32; c++)
+ curr_class[c] = ~cd->cbits[c + *code * 32];
+
+ code++;
+ break;
+
+ case OP_TYPE:
+ code++;
+ can_be_empty = FALSE;
+ REPEATTYPE:
+ if (!*code)
+ memset (curr_class, ~0, 32);
+ else
+ for (c = 0; c < 32; c++)
+ curr_class[c] = cd->cbits[c + *code * 32];
+
+ code++;
+ break;
+
+ case OP_CHARS:
+ code++;
+ can_be_empty = FALSE;
+ set_bit (curr_class, code[1], caseless, cd);
+ code += 1 + (int) *code;
+ memset (end, 0, 32);
+ set_bit (end, code[-1], caseless, cd);
+ break;
+
+ case OP_ANY:
+ code++;
+ can_be_empty = FALSE;
+ memset (curr_class, ~0, 32);
+ break;
+
+ case OP_NOT:
+ code++;
+ can_be_empty = FALSE;
+ REPEATNOT:
+ set_bit (curr_class, *code++, caseless, cd);
+ for (c = 0; c < 32; c++)
+ curr_class[c] = ~curr_class[c];
+
+ break;
+
+ /* One or more character type fudges the pointer and restarts. */
+
+ case OP_TYPEEXACT:
+ code += 2;
+
+ case OP_TYPE_MAXPLUS:
+ case OP_TYPE_MINPLUS:
+ case OP_TYPE_ONCEPLUS:
+ code++;
+ can_be_empty = FALSE;
+ goto REPEATTYPE;
+
+ /* Zero or more repeats of character types set the bits and then
+ try again. */
+
+ case OP_TYPE_MAXUPTO:
+ case OP_TYPE_MINUPTO:
+ case OP_TYPE_ONCEUPTO:
+ code += 2; /* Fall through */
+
+ case OP_TYPE_MAXSTAR:
+ case OP_TYPE_MINSTAR:
+ case OP_TYPE_ONCESTAR:
+ case OP_TYPE_MAXQUERY:
+ case OP_TYPE_MINQUERY:
+ case OP_TYPE_ONCEQUERY:
+ code++;
+ goto REPEATTYPE;
+ break;
+
+ /* One or more character type fudges the pointer and restarts. */
+
+ case OP_TYPENOTEXACT:
+ code += 2; /* Fall through */
+
+ case OP_TYPENOT_MAXPLUS:
+ case OP_TYPENOT_MINPLUS:
+ case OP_TYPENOT_ONCEPLUS:
+ code++;
+ can_be_empty = FALSE;
+ goto REPEATTYPENOT;
+
+ case OP_TYPENOT_MAXUPTO:
+ case OP_TYPENOT_MINUPTO:
+ case OP_TYPENOT_ONCEUPTO:
+ code += 2; /* Fall through */
+
+ case OP_TYPENOT_MAXSTAR:
+ case OP_TYPENOT_MINSTAR:
+ case OP_TYPENOT_ONCESTAR:
+ case OP_TYPENOT_MAXQUERY:
+ case OP_TYPENOT_MINQUERY:
+ case OP_TYPENOT_ONCEQUERY:
+ code++;
+ goto REPEATTYPENOT;
+
+ /* One or more character type fudges the pointer and restarts. */
+
+ case OP_EXACT:
+ code += 2;
+
+ case OP_MAXPLUS:
+ case OP_MINPLUS:
+ case OP_ONCEPLUS:
+ code++;
+ can_be_empty = FALSE;
+ goto REPEATCHARS;
+
+ /* Zero or more repeats of character types set the bits and then
+ try again. */
+
+ case OP_MAXUPTO:
+ case OP_MINUPTO:
+ case OP_ONCEUPTO:
+ code += 2; /* Fall through */
+
+ case OP_MAXSTAR:
+ case OP_MINSTAR:
+ case OP_ONCESTAR:
+ case OP_MAXQUERY:
+ case OP_MINQUERY:
+ case OP_ONCEQUERY:
+ code++;
+
+ REPEATCHARS:
+ set_bit (curr_class, *code++, caseless, cd);
+ break;
+
+ /* One or more character type fudges the pointer and restarts. */
+
+ case OP_NOTEXACT:
+ code += 2; /* Fall through */
+
+ case OP_NOT_MAXPLUS:
+ case OP_NOT_MINPLUS:
+ case OP_NOT_ONCEPLUS:
+ can_be_empty = FALSE;
+ code++;
+ goto REPEATNOT;
+
+ case OP_NOT_MAXUPTO:
+ case OP_NOT_MINUPTO:
+ case OP_NOT_ONCEUPTO:
+ code += 2; /* Fall through */
+
+ case OP_NOT_MAXSTAR:
+ case OP_NOT_MINSTAR:
+ case OP_NOT_ONCESTAR:
+ case OP_NOT_MAXQUERY:
+ case OP_NOT_MINQUERY:
+ case OP_NOT_ONCEQUERY:
+ code++;
+ goto REPEATNOT;
+
+ /* Character class: set the bits and either carry on or not,
+ according to the repeat count. */
+
+ case OP_CLASS:
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_ONCESTAR:
+ case OP_CL_MAXPLUS:
+ case OP_CL_MINPLUS:
+ case OP_CL_ONCEPLUS:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CL_ONCEQUERY:
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ case OP_CL_ONCERANGE:
+ {
+ code++;
+ for (c = 0; c < 32; c++)
+ curr_class[c] |= code[c];
+ code += 32;
+ switch (code[-33])
+ {
+ case OP_CL_MAXSTAR:
+ case OP_CL_MINSTAR:
+ case OP_CL_ONCESTAR:
+ case OP_CL_MAXQUERY:
+ case OP_CL_MINQUERY:
+ case OP_CL_ONCEQUERY:
+ break;
+
+ case OP_CL_MAXRANGE:
+ case OP_CL_MINRANGE:
+ case OP_CL_ONCERANGE:
+ if (((code[1] << 8) + code[2]) == 0)
+ code += 4;
+ else
+ can_be_empty = FALSE;
+ break;
+
+ default:
+ can_be_empty = FALSE;
+ break;
+ }
+ }
+ break; /* End of class handling */
+
+ /* Character class: set the bits and either carry on or not,
+ according to the repeat count. */
+
+ case OP_REF:
+ case OP_REF_MAXSTAR:
+ case OP_REF_MINSTAR:
+ case OP_REF_ONCESTAR:
+ case OP_REF_MAXPLUS:
+ case OP_REF_MINPLUS:
+ case OP_REF_ONCEPLUS:
+ case OP_REF_MAXQUERY:
+ case OP_REF_MINQUERY:
+ case OP_REF_ONCEQUERY:
+ case OP_REF_MAXRANGE:
+ case OP_REF_MINRANGE:
+ case OP_REF_ONCERANGE:
+ {
+ int number = (code[1] << 8) | code[2];
+ code += 3;
+ memcpy (curr_class, bracket_start[number], 32);
+ memcpy (end, bracket_end[number], 32);
+ switch (code[-3])
+ {
+ case OP_REF_MAXSTAR:
+ case OP_REF_MINSTAR:
+ case OP_REF_ONCESTAR:
+ case OP_REF_MAXQUERY:
+ case OP_REF_MINQUERY:
+ case OP_REF_ONCEQUERY:
+ break;
+
+ case OP_REF_MAXRANGE:
+ case OP_REF_MINRANGE:
+ case OP_REF_ONCERANGE:
+ if (((code[1] << 8) + code[2]) == 0)
+ code += 4;
+ break;
+ }
+ }
+ break; /* End of class handling */
+
+ default:
+ if ((int) *code >= OP_BRA || *code == OP_ONCE || *code == OP_COND)
+ {
+ can_be_empty = !prune_bracket(¤t, &code,
+ bracket_start, bracket_end,
+ caseless, cd, &curr_class);
+ break;
+ }
+
+ printf ("What's this `%s'?\n", pcre_OP_names[*code]);
+ abort();
+
+ } /* End of switch */
+
+ if (previous)
+ {
+ /* Check if we can prune the last path. The check
+ on can_be_empty avoids pruning b* in b*c*b+. */
+ if (!can_be_empty)
+ {
+ for (i = 0; i < 32; i++)
+ if (curr_class[i] & prev_class[i])
+ break;
+
+ if (i == 32)
+ *previous = pruned[*previous];
+ }
+ }
+
+ if (*current != OP_CHARS &&
+ (*current <= OP_REF || *current >= OP_REF_ONCERANGE))
+ {
+ if (can_be_empty)
+ {
+ int i;
+ for (i = 0; i < 32; i++)
+ end[i] |= curr_class[i];
+ }
+ else
+ memcpy (end, curr_class, 32);
+ }
+
+ /* We found the starting class for this bracket (or part of it if
+ there are alternative branches). */
+ if (!found_start)
+ {
+ found_start = !can_be_empty;
+ for (i = 0; i < 32; i++)
+ start[i] |= curr_class[i];
+ }
+
+ if (is_final_opcode)
+ {
+ *prevptr = current;
+ *codeptr = code;
+ memcpy (end, curr_class, 32);
+ return found_start;
+ }
+
+ previous = (pruned[*current] == *current) ? NULL : current;
+ current = code;
+ }
+}
+
+
+
+/*************************************************
+* Prune paths from a compiled expression *
+*************************************************/
+
+/* This function is handed a compiled expression of which it must prune
+ impossible backtracking paths. This is done by replacing _MAX* and
+ _MIN* opcodes by the corresponding _ONCE* opcodes.
+
+ Arguments:
+ re points to the compiled expression
+ caseless the caseless flag
+ cd the block with char table pointers
+ */
+
+void
+prune_backtracking_paths (re, caseless, cd)
+ const pcre *re;
+ BOOL caseless;
+ compile_data *cd;
+{
+ bitset curr_class;
+ uschar *code = re->code, *current;
+
+ bitset *bracket_start = (bitset *)
+ alloca(sizeof(bitset) * (1 + re->top_bracket));
+
+ bitset *bracket_end = (bitset *)
+ alloca(sizeof(bitset) * (1 + re->top_bracket));
+
+ prune_bracket (¤t, &code, bracket_start, bracket_end,
+ caseless, cd, &curr_class);
+}
+
+
+
+
+/*************************************************
+* Study a compiled expression *
+*************************************************/
+
+/* This function is handed a compiled expression that it must study to produce
+ information that will speed up the matching. It returns a pcre_extra block
+ which then gets handed back to pcre_exec().
+
+ Arguments:
+ re points to the compiled expression
+ options contains option bits
+ errorptr points to where to place error messages;
+ set NULL unless error
+
+ Returns: pointer to a pcre_extra block,
+ NULL on error or if no optimization possible
+ */
+
+pcre_extra *
+pcre_study (re, options, errorptr)
+ const pcre *re;
+ int options;
+ const char **errorptr;
+{
+ pcre_extra *extra, myextra;
+ compile_data compile_block;
+ int length;
+ int caseless;
+
+ *errorptr = NULL;
+
+ if (re == NULL || re->magic_number != MAGIC_NUMBER)
+ {
+ *errorptr = "argument is not a compiled regular expression";
+ return NULL;
+ }
+
+ if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)
+ {
+ *errorptr = "unknown or incorrect option bit(s) set";
+ return NULL;
+ }
+
+
+ /* Set the character tables in the block which is passed around */
+
+ compile_block.lcc = re->tables + lcc_offset;
+ compile_block.fcc = re->tables + fcc_offset;
+ compile_block.cbits = re->tables + cbits_offset;
+ compile_block.ctypes = re->tables + ctypes_offset;
+ caseless = (re->options & PCRE_CASELESS) != 0;
+
+ if (!(options & PCRE_STUDY_NO_PRUNE))
+ prune_backtracking_paths(re, caseless, &compile_block);
+
+ /* For an anchored pattern, or a multiline pattern that matches only at
+ "line starts", no further processing at present. */
+
+ if ((re->options & (PCRE_ANCHORED | PCRE_STARTLINE)) != 0
+ || (options & PCRE_STUDY_NO_START))
+ return NULL;
+
+ /* See if we can find a fixed length initial string for the pattern. */
+
+ memset ((char *) &myextra, 0, sizeof (myextra));
+
+ if ((length = set_boyer_moore (re->code, myextra.data.bmtable, 0,
+ caseless, &compile_block)) > 1)
+ {
+ int i;
+ myextra.options = PCRE_STUDY_BM;
+ for (i = 0; i < 257; i++)
+ myextra.data.bmtable[i] = length - myextra.data.bmtable[i];
+ }
+ else
+ {
+ if ((re->options & PCRE_FIRSTSET) != 0)
+ return NULL;
+
+ /* See if we can find a fixed set of initial characters for the pattern. */
+
+ memset ((char *) &myextra, 0, sizeof (myextra));
+ if (set_start_bits (re->code, myextra.data.start_bits,
+ caseless, &compile_block))
+ myextra.options = PCRE_STUDY_MAPPED;
+ }
+
+ if (!myextra.options)
+ return NULL;
+
+ /* Get an "extra" block and put the information therein. */
+
+ extra = (pcre_extra *) (pcre_malloc) (sizeof (pcre_extra));
+ if (extra == NULL)
+ {
+ *errorptr = "failed to get memory";
+ return NULL;
+ }
+
+ memcpy ((char *) extra, (char *) &myextra, sizeof (myextra));
+ return (pcre_extra *) extra;
+}
diff --git a/pcre/regsub.c b/pcre/regsub.c
new file mode 100644
index 0000000..8874369
--- /dev/null
+++ b/pcre/regsub.c
@@ -0,0 +1,242 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ This is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language. See
+ the file Tech.Notes for some information on the internals.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+ */
+
+/* This module contains some convenience functions for extracting substrings
+ from the subject string after a regex match has succeeded. The original idea
+ for these functions came from Scott Wimer . */
+
+
+/* Include the internals header, which itself includes Standard C headers plus
+ the external pcre header. */
+
+#include "internal.h"
+
+
+
+/*************************************************
+* Copy captured string to given buffer *
+*************************************************/
+
+/* This function copies a single captured substring into a given buffer.
+ Note that we use memcpy() rather than strncpy() in case there are binary zeros
+ in the string.
+
+ Arguments:
+ subject the subject string that was matched
+ ovector pointer to the offsets table
+ stringcount the number of substrings that were captured
+ (i.e. the yield of the pcre_exec call, unless
+ that was zero, in which case it should be 1/3
+ of the offset table size)
+ stringnumber the number of the required substring
+ buffer where to put the substring
+ size the size of the buffer
+
+ Returns: if successful:
+ the length of the copied string, not including the zero
+ that is put on the end; can be zero
+ if not successful:
+ PCRE_ERROR_NOMEMORY (-6) buffer too small
+ PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
+ */
+
+int
+pcre_copy_substring (subject, ovector, stringcount, stringnumber, buffer, size)
+ const char *subject;
+ int *ovector;
+ int stringcount;
+ int stringnumber;
+ char *buffer;
+ int size;
+{
+ int yield;
+ if (stringnumber < 0 || stringnumber >= stringcount)
+ return PCRE_ERROR_NOSUBSTRING;
+ stringnumber *= 2;
+ yield = ovector[stringnumber + 1] - ovector[stringnumber];
+ if (size < yield + 1)
+ return PCRE_ERROR_NOMEMORY;
+ memcpy (buffer, subject + ovector[stringnumber], yield);
+ buffer[yield] = 0;
+ return yield;
+}
+
+
+
+/*************************************************
+* Copy all captured strings to new store *
+*************************************************/
+
+/* This function gets one chunk of store and builds a list of pointers and all
+ of the captured substrings in it. A NULL pointer is put on the end of the list.
+
+ Arguments:
+ subject the subject string that was matched
+ ovector pointer to the offsets table
+ stringcount the number of substrings that were captured
+ (i.e. the yield of the pcre_exec call, unless
+ that was zero, in which case it should be 1/3
+ of the offset table size)
+ listptr set to point to the list of pointers
+
+ Returns: if successful: 0
+ if not successful:
+ PCRE_ERROR_NOMEMORY (-6) failed to get store
+ */
+
+int
+pcre_get_substring_list (subject, ovector, stringcount, listptr)
+ const char *subject;
+ int *ovector;
+ int stringcount;
+ const char ***listptr;
+{
+ int i;
+ int size = sizeof (char *);
+ int double_count = stringcount * 2;
+ char **stringlist;
+ char *p;
+
+ for (i = 0; i < double_count; i += 2)
+ size += sizeof (char *) + ovector[i + 1] - ovector[i] + 1;
+
+ stringlist = (char **) (pcre_malloc) (size);
+ if (stringlist == NULL)
+ return PCRE_ERROR_NOMEMORY;
+
+ *listptr = (const char **) stringlist;
+ p = (char *) (stringlist + stringcount + 1);
+
+ for (i = 0; i < double_count; i += 2)
+ {
+ int len = ovector[i + 1] - ovector[i];
+ memcpy (p, subject + ovector[i], len);
+ *stringlist++ = p;
+ p += len;
+ *p++ = 0;
+ }
+
+ *stringlist = NULL;
+ return 0;
+}
+
+
+
+/*************************************************
+* Free store obtained by get_substring_list *
+*************************************************/
+
+/* This function exists for the benefit of people calling PCRE from non-C
+ programs that can call its functions, but not free() or (pcre_free)() directly.
+
+ Argument: the result of a previous pcre_get_substring_list()
+ Returns: nothing
+ */
+
+void
+pcre_free_substring_list (pointer)
+ const char **pointer;
+{
+ (pcre_free) ((void *) pointer);
+}
+
+
+
+/*************************************************
+* Copy captured string to new store *
+*************************************************/
+
+/* This function copies a single captured substring into a piece of new
+ store
+
+ Arguments:
+ subject the subject string that was matched
+ ovector pointer to the offsets table
+ stringcount the number of substrings that were captured
+ (i.e. the yield of the pcre_exec call, unless
+ that was zero, in which case it should be 1/3
+ of the offset table size)
+ stringnumber the number of the required substring
+ stringptr where to put a pointer to the substring
+
+ Returns: if successful:
+ the length of the string, not including the zero that
+ is put on the end; can be zero
+ if not successful:
+ PCRE_ERROR_NOMEMORY (-6) failed to get store
+ PCRE_ERROR_NOSUBSTRING (-7) substring not present
+ */
+
+int
+pcre_get_substring (subject, ovector, stringcount, stringnumber, stringptr)
+ const char *subject;
+ int *ovector;
+ int stringcount;
+ int stringnumber;
+ const char **stringptr;
+{
+ int yield;
+ char *substring;
+ if (stringnumber < 0 || stringnumber >= stringcount)
+ return PCRE_ERROR_NOSUBSTRING;
+ stringnumber *= 2;
+ yield = ovector[stringnumber + 1] - ovector[stringnumber];
+ substring = (char *) (pcre_malloc) (yield + 1);
+ if (substring == NULL)
+ return PCRE_ERROR_NOMEMORY;
+ memcpy (substring, subject + ovector[stringnumber], yield);
+ substring[yield] = 0;
+ *stringptr = substring;
+ return yield;
+}
+
+
+
+/*************************************************
+* Free store obtained by get_substring *
+*************************************************/
+
+/* This function exists for the benefit of people calling PCRE from non-C
+ programs that can call its functions, but not free() or (pcre_free)() directly.
+
+ Argument: the result of a previous pcre_get_substring()
+ Returns: nothing
+ */
+
+void
+pcre_free_substring (pointer)
+ const char *pointer;
+{
+ (pcre_free) ((void *) pointer);
+}
diff --git a/pcre/regtables.c b/pcre/regtables.c
new file mode 100644
index 0000000..bb1bbe8
--- /dev/null
+++ b/pcre/regtables.c
@@ -0,0 +1,135 @@
+/*************************************************
+* Perl-Compatible Regular Expressions *
+*************************************************/
+
+/*
+ PCRE is a library of functions to support regular expressions whose syntax
+ and semantics are as close as possible to those of the Perl 5 language.
+
+ Written by: Philip Hazel
+
+ Copyright (c) 1997-2000 University of Cambridge
+
+ -----------------------------------------------------------------------------
+ Permission is granted to anyone to use this software for any purpose on any
+ computer system, and to redistribute it freely, subject to the following
+ restrictions:
+
+ 1. This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 4. If PCRE is embedded in any software that is released under the GNU
+ General Purpose Licence (GPL), then the terms of that licence shall
+ supersede any condition above with which it is incompatible.
+ -----------------------------------------------------------------------------
+
+ See the file Tech.Notes for some information on the internals.
+ */
+
+#include "internal.h"
+
+#if !defined HAVE_ISBLANK && !defined isblank
+# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
+#endif
+
+/*************************************************
+* Create PCRE character tables *
+*************************************************/
+
+/* This function builds a set of character tables for use by PCRE and returns
+ a pointer to them. They are build using the ctype functions, and consequently
+ their contents will depend upon the current locale setting. When compiled as
+ part of the library, the store is obtained via pcre_malloc().
+
+ Arguments: none
+ Returns: pointer to the contiguous block of data
+ */
+
+const unsigned char *
+pcre_maketables ()
+{
+ unsigned char *yield, *p;
+ int i;
+
+ yield = (unsigned char *) (pcre_malloc) (tables_length);
+ if (yield == NULL)
+ return NULL;
+ p = yield;
+
+ /* First comes the lower casing table */
+ for (i = 0; i < 256; i++)
+ *p++ = tolower (i);
+
+ /* Next the case-flipping table */
+ for (i = 0; i < 256; i++)
+ *p++ = islower (i) ? toupper (i) : tolower (i);
+
+ /* Then the character class tables. Don't try to be clever and save effort
+ on exclusive ones - in some locales things may be different. */
+ memset (p, 0, cbit_length);
+ for (i = 0; i < 256; i++)
+ {
+ if (isdigit (i))
+ {
+ p[cbit_digit + i / 8] |= 1 << (i & 7);
+ p[cbit_word + i / 8] |= 1 << (i & 7);
+ }
+ if (isupper (i))
+ {
+ p[cbit_upper + i / 8] |= 1 << (i & 7);
+ p[cbit_word + i / 8] |= 1 << (i & 7);
+ }
+ if (islower (i))
+ {
+ p[cbit_lower + i / 8] |= 1 << (i & 7);
+ p[cbit_word + i / 8] |= 1 << (i & 7);
+ }
+ if (i == '_')
+ p[cbit_word + i / 8] |= 1 << (i & 7);
+ if (isspace (i))
+ p[cbit_space + i / 8] |= 1 << (i & 7);
+ if (isxdigit (i))
+ p[cbit_xdigit + i / 8] |= 1 << (i & 7);
+ if (isgraph (i))
+ p[cbit_graph + i / 8] |= 1 << (i & 7);
+ if (isprint (i))
+ p[cbit_print + i / 8] |= 1 << (i & 7);
+ if (ispunct (i))
+ p[cbit_punct + i / 8] |= 1 << (i & 7);
+ if (iscntrl (i))
+ p[cbit_cntrl + i / 8] |= 1 << (i & 7);
+ if (isblank (i))
+ p[cbit_blank + i / 8] |= 1 << (i & 7);
+ }
+ p += cbit_length;
+
+ /* Finally, the character type table */
+ for (i = 0; i < 256; i++)
+ {
+ int x = 0;
+ if (isspace (i))
+ x += ctype_space;
+ if (isalpha (i))
+ x += ctype_letter;
+ if (isdigit (i))
+ x += ctype_digit;
+ if (isxdigit (i))
+ x += ctype_xdigit;
+ if (isalnum (i) || i == '_')
+ x += ctype_word;
+ if (i && strchr ("*+?{^.$|()[", i) != 0)
+ x += ctype_meta;
+ if (i == '\n')
+ x += ctype_newline;
+ *p++ = x;
+ }
+
+ return yield;
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3c06d1e..76dbe12 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,8 +1,9 @@
+pcre/internal.h
+pcre/pcregrep.c
+pcre/regexp.c
+pcre/regstudy.c
sed/compile.c
sed/execute.c
sed/regexp.c
sed/sed.c
lib/utils.c
-lib/regcomp.c
-lib/regexec.c
-lib/regex_internal.c
diff --git a/po/af.po b/po/af.po
index 845b2c2..92558c2 100644
--- a/po/af.po
+++ b/po/af.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.9\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-01-11 21:06+0000\n"
"Last-Translator: Ysbeer \n"
"Language-Team: Afrikaans \n"
@@ -16,6 +16,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=n!=1;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Onbekende opsie vir `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "leesfout op %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Ongeldige karakterklasnaam"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Ongepaarde `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Onbekende opsie vir `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Vermiste instruksie"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Regex te groot"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "opsie `e' word nie ondersteun nie"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Ongeldige inhoud binne \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -360,74 +560,47 @@ msgstr "leesfout op %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: Kan nie %s lees nie: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Sukses"
+#~ msgid "Success"
+#~ msgstr "Sukses"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Geen paring"
+#~ msgid "No match"
+#~ msgstr "Geen paring"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Ongeldige regex"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Ongeldige regex"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Ongeldige kollasiekarakter"
+#~ msgid "Invalid collation character"
+#~ msgstr "Ongeldige kollasiekarakter"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Ongeldige karakterklasnaam"
+#~ msgid "Trailing backslash"
+#~ msgstr "Sleep terugstreep"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Sleep terugstreep"
+#~ msgid "Invalid back reference"
+#~ msgstr "Ongeldige terugverwysing"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Ongeldige terugverwysing"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Ongepaarde [ of [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Ongepaarde [ of [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Ongepaarde ( or \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Ongepaarde ( or \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Ongepaarde \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Ongepaarde \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Ongeldige bereikseinde"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Ongeldige inhoud binne \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Geheue uitgeput"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Ongeldige bereikseinde"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Ongeldige vorige regex"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Geheue uitgeput"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Premature einde vir regex"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Ongeldige vorige regex"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Ongepaarde ) of \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Premature einde vir regex"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Regex te groot"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Ongepaarde ) of \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Geen vorige regex nie"
+#~ msgid "No previous regular expression"
+#~ msgstr "Geen vorige regex nie"
diff --git a/po/ca.po b/po/ca.po
index 69094a1..f19c64c 100644
--- a/po/ca.po
+++ b/po/ca.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.1.1\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-07-10 05:51+0200\n"
"Last-Translator: Jordi Mallach \n"
"Language-Team: Catalan \n"
@@ -15,6 +15,206 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n!=1;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "opció desconeguda per a «s»"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "error de lectura en %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Nom de classe de caràcter no vàlid"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "«{» no emparellat"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "opció desconeguda per a «s»"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "cal una ordre"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "L'expressió regular és massa gran"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "l'opció «e» no està suportada"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "El contingut de \\{\\} no és vàlid"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr "múltiples «!»"
@@ -373,74 +573,47 @@ msgstr "error de lectura en %s: %s"
msgid "cannot rename %s: %s"
msgstr "no es pot reanomenar %s: %s"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Èxit"
+#~ msgid "Success"
+#~ msgstr "Èxit"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Sense parella"
+#~ msgid "No match"
+#~ msgstr "Sense parella"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Expressió regular no vàlida"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Expressió regular no vàlida"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "El caràcter de comparació no és vàlid"
+#~ msgid "Invalid collation character"
+#~ msgstr "El caràcter de comparació no és vàlid"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nom de classe de caràcter no vàlid"
+#~ msgid "Trailing backslash"
+#~ msgstr "Barra invertida al final"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Barra invertida al final"
+#~ msgid "Invalid back reference"
+#~ msgstr "La referència cap enrere no és vàlida"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "La referència cap enrere no és vàlida"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[ o [^ no emparellat"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[ o [^ no emparellat"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "«(» o \\( no emparellat"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "«(» o \\( no emparellat"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{ no emparellat"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{ no emparellat"
+#~ msgid "Invalid range end"
+#~ msgstr "El rang final no és vàlid"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "El contingut de \\{\\} no és vàlid"
+#~ msgid "Memory exhausted"
+#~ msgstr "Memòria exhaurida"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "El rang final no és vàlid"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "L'expressió regular precedent no vàlida"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Memòria exhaurida"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Fi prematur de l'expressió regular"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "L'expressió regular precedent no vàlida"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ") o \\) no emparellat"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Fi prematur de l'expressió regular"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "L'expressió regular és massa gran"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ") o \\) no emparellat"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "No hi ha una expressió regular prèvia"
+#~ msgid "No previous regular expression"
+#~ msgstr "No hi ha una expressió regular prèvia"
diff --git a/po/cs.po b/po/cs.po
index f041a1f..4855d77 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 3.02.80\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2001-08-05 19:52+02:00\n"
"Last-Translator: Vladimir Michl \n"
"Language-Team: Czech \n"
@@ -14,6 +14,202 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Report-Msgid-Bugs-To: \n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Neznámý pøepínaè pro `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "chyba pøi ètení z %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+msgid "invalid escape sequence in character class"
+msgstr ""
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Neodpovídající `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Neznámý pøepínaè pro `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Chybìjící pøíkaz"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+msgid "regular expression too large"
+msgstr ""
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+msgid "POSIX collating elements are not supported"
+msgstr ""
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+msgid "invalid repeat counts in {}"
+msgstr ""
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -348,78 +544,18 @@ msgstr "chyba p
msgid "cannot rename %s: %s"
msgstr "%s: %s nelze èíst: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr ""
-
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr ""
-
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr ""
-
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr ""
-
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr ""
-
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr ""
-
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr ""
-
-#: lib/regcomp.c:171
#, fuzzy
-msgid "Unmatched [ or [^"
-msgstr "Neodpovídající `{'"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Neodpovídající `{'"
-#: lib/regcomp.c:174
#, fuzzy
-msgid "Unmatched ( or \\("
-msgstr "Neodpovídající `{'"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Neodpovídající `{'"
-#: lib/regcomp.c:177
#, fuzzy
-msgid "Unmatched \\{"
-msgstr "Neodpovídající `{'"
+#~ msgid "Unmatched \\{"
+#~ msgstr "Neodpovídající `{'"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr ""
-
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr ""
-
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr ""
-
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr ""
-
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr ""
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr ""
-
-#: lib/regcomp.c:198
#, fuzzy
-msgid "Unmatched ) or \\)"
-msgstr "Neodpovídající `{'"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr ""
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Neodpovídající `{'"
diff --git a/po/da.po b/po/da.po
index c137158..bbafe4d 100644
--- a/po/da.po
+++ b/po/da.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.8\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-10-25 08:00+0200\n"
"Last-Translator: Byrial Ole Jensen \n"
"Language-Team: Danish \n"
@@ -15,6 +15,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Ukendt tilvalg til 's'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "læsefejl på %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Ugyldigt navn på tegnklasse"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Uparret '{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Ukendt tilvalg til 's'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Der mangler en kommando"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Regulært udtryk for stort"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "tilvalg 'e' er ikke understøttet"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Ugyldigt indhold af \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -357,74 +557,47 @@ msgstr "l
msgid "cannot rename %s: %s"
msgstr "%s: kan ikke læse %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Godt resultat"
+#~ msgid "Success"
+#~ msgstr "Godt resultat"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Intet resultat"
+#~ msgid "No match"
+#~ msgstr "Intet resultat"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Ugyldigt regulært udtryk"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Ugyldigt regulært udtryk"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Ugyldigt sorteringstegn"
+#~ msgid "Invalid collation character"
+#~ msgstr "Ugyldigt sorteringstegn"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Ugyldigt navn på tegnklasse"
+#~ msgid "Trailing backslash"
+#~ msgstr "Afsluttende omvendt skråstreg"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Afsluttende omvendt skråstreg"
+#~ msgid "Invalid back reference"
+#~ msgstr "Ugyldig reference bagud"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Ugyldig reference bagud"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Uparret [ eller [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Uparret [ eller [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Uparret ( eller \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Uparret ( eller \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Uparret \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Uparret \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Ugyldig slutning på område"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Ugyldigt indhold af \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Hukommelsen opbrugt"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Ugyldig slutning på område"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Ugyldigt forudgående regulært udtryk"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Hukommelsen opbrugt"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Ufuldstændigt regulært udtryk"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Ugyldigt forudgående regulært udtryk"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Uparret ) eller \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Ufuldstændigt regulært udtryk"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Regulært udtryk for stort"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Uparret ) eller \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Intet forudgående regulært udtryk"
+#~ msgid "No previous regular expression"
+#~ msgstr "Intet forudgående regulært udtryk"
diff --git a/po/de.po b/po/de.po
index 2e6d6f8..6064ff6 100644
--- a/po/de.po
+++ b/po/de.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.6\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-03-21 22:03:41+0100\n"
"Last-Translator: Walter Koch \n"
"Language-Team: German \n"
@@ -15,6 +15,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Unbekannte Option betreffs `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "Lesefehler in %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Ungültige Zeichenklassenname"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Nicht paarweises `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Unbekannte Option betreffs `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Fehlender Befehl"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Regulärer Ausdruck ist zu groß"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "Option `e' wird nicht unterstützt"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Ungültiger Inhalt in \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -362,74 +562,47 @@ msgstr "Lesefehler in %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: kann %s nicht lesen: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Erfolgreich"
+#~ msgid "Success"
+#~ msgstr "Erfolgreich"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Keine Übereinstimmung"
+#~ msgid "No match"
+#~ msgstr "Keine Übereinstimmung"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Ungültiger regulärer Ausdruck"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Ungültiger regulärer Ausdruck"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Ungültiger Vergleichszeichen"
+#~ msgid "Invalid collation character"
+#~ msgstr "Ungültiger Vergleichszeichen"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Ungültige Zeichenklassenname"
+#~ msgid "Trailing backslash"
+#~ msgstr "Abschliessender Backslash"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Abschliessender Backslash"
+#~ msgid "Invalid back reference"
+#~ msgstr "Ungültiger Rückwärtsverweis"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Ungültiger Rückwärtsverweis"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Nicht paarweises [ bzw. [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Nicht paarweises [ bzw. [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Nicht paarweises ( bzw. \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Nicht paarweises ( bzw. \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Nicht paarweises \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Nicht paarweises \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Ungültiges Bereichende"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Ungültiger Inhalt in \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Speicher erschöpft"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Ungültiges Bereichende"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Vorheriger regulärer Ausdruck ist ungültig"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Speicher erschöpft"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Regulärer Ausdruck endet zu früh"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Vorheriger regulärer Ausdruck ist ungültig"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Nicht paarweises ) bzw. \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Regulärer Ausdruck endet zu früh"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Regulärer Ausdruck ist zu groß"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Nicht paarweises ) bzw. \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Kein vorheriger regulärer Ausdruck"
+#~ msgid "No previous regular expression"
+#~ msgstr "Kein vorheriger regulärer Ausdruck"
diff --git a/po/el.po b/po/el.po
index 08d1050..31acec6 100644
--- a/po/el.po
+++ b/po/el.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: GNU sed 3.02.80\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2002-03-08 12:57+0000\n"
"Last-Translator: Simos Xenitellis \n"
"Language-Team: Greek \n"
@@ -14,6 +14,206 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Report-Msgid-Bugs-To: \n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "¶ãíùóôç åðéëïãÞ ãéá ôï `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "óöÜëìá áíÜãíùóçò óôï %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "ìç Ýãêõñï áêïëïõèßá äéáöõãÞò óå êëÜóç ÷áñáêôÞñùí"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Áôáßñéáóôï `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "¶ãíùóôç åðéëïãÞ ãéá ôï `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Ëåßðåé ç åíôïëÞ"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "ðïëý ìåãÜëç êáíïíéêÞ Ýêöñáóç"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "äåí õðïóôçñßæåôáé ç åðéëïãÞ `e'"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "ìç Ýãêõñï ðåñéå÷üìåíï äåéêôþí åðáíÜëçøçò {}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -351,85 +551,37 @@ msgstr "
msgid "cannot rename %s: %s"
msgstr "%s: áäõíáìßá óôçí áíÜãíùóç %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr ""
-
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr ""
-
-#: lib/regcomp.c:156
#, fuzzy
-msgid "Invalid regular expression"
-msgstr "Äåí âñÝèçêå ðñïçãïýìåíç êáíïíéêÞ Ýêöñáóç"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Äåí âñÝèçêå ðñïçãïýìåíç êáíïíéêÞ Ýêöñáóç"
-#: lib/regcomp.c:159
#, fuzzy
-msgid "Invalid collation character"
-msgstr "ìç Ýãêõñï áêïëïõèßá äéáöõãÞò óå êëÜóç ÷áñáêôÞñùí"
+#~ msgid "Invalid collation character"
+#~ msgstr "ìç Ýãêõñï áêïëïõèßá äéáöõãÞò óå êëÜóç ÷áñáêôÞñùí"
-#: lib/regcomp.c:162
#, fuzzy
-msgid "Invalid character class name"
-msgstr "ìç Ýãêõñï áêïëïõèßá äéáöõãÞò óå êëÜóç ÷áñáêôÞñùí"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Áôáßñéáóôï `{'"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr ""
-
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr ""
-
-#: lib/regcomp.c:171
#, fuzzy
-msgid "Unmatched [ or [^"
-msgstr "Áôáßñéáóôï `{'"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Áôáßñéáóôï `{'"
-#: lib/regcomp.c:174
#, fuzzy
-msgid "Unmatched ( or \\("
-msgstr "Áôáßñéáóôï `{'"
+#~ msgid "Unmatched \\{"
+#~ msgstr "Áôáßñéáóôï `{'"
-#: lib/regcomp.c:177
#, fuzzy
-msgid "Unmatched \\{"
-msgstr "Áôáßñéáóôï `{'"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Äåí âñÝèçêå ðñïçãïýìåíç êáíïíéêÞ Ýêöñáóç"
-#: lib/regcomp.c:180
#, fuzzy
-msgid "Invalid content of \\{\\}"
-msgstr "ìç Ýãêõñï ðåñéå÷üìåíï äåéêôþí åðáíÜëçøçò {}"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Äåí âñÝèçêå ðñïçãïýìåíç êáíïíéêÞ Ýêöñáóç"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr ""
-
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr ""
-
-#: lib/regcomp.c:189
#, fuzzy
-msgid "Invalid preceding regular expression"
-msgstr "Äåí âñÝèçêå ðñïçãïýìåíç êáíïíéêÞ Ýêöñáóç"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Áôáßñéáóôï `{'"
-#: lib/regcomp.c:192
-#, fuzzy
-msgid "Premature end of regular expression"
-msgstr "Äåí âñÝèçêå ðñïçãïýìåíç êáíïíéêÞ Ýêöñáóç"
-
-#: lib/regcomp.c:195
-#, fuzzy
-msgid "Regular expression too big"
-msgstr "ðïëý ìåãÜëç êáíïíéêÞ Ýêöñáóç"
-
-#: lib/regcomp.c:198
-#, fuzzy
-msgid "Unmatched ) or \\)"
-msgstr "Áôáßñéáóôï `{'"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Äåí âñÝèçêå ðñïçãïýìåíç êáíïíéêÞ Ýêöñáóç"
+#~ msgid "No previous regular expression"
+#~ msgstr "Äåí âñÝèçêå ðñïçãïýìåíç êáíïíéêÞ Ýêöñáóç"
diff --git a/po/eo.po b/po/eo.po
index 1ab5220..b8ca4cb 100644
--- a/po/eo.po
+++ b/po/eo.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: GNU sed 4.0.8\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-10-26 20:57+0000\n"
"Last-Translator: Edmund GRIMLEY EVANS \n"
"Language-Team: Esperanto \n"
@@ -15,6 +15,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Nekonata opcio por 's'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "legeraro ĉe %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Nevalida nomo de signoklaso"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Neparigita '{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Nekonata opcio por 's'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Mankas komando"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Regula esprimo tro granda"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "opcio 'e' ne realigita"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Nevalida enhavo de \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -357,74 +557,47 @@ msgstr "legeraro ĉe %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: ne povas legi %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Sukceso"
+#~ msgid "Success"
+#~ msgstr "Sukceso"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Maltrafo"
+#~ msgid "No match"
+#~ msgstr "Maltrafo"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Nevalida regula esprimo"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Nevalida regula esprimo"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Nevalida kunfanda signo"
+#~ msgid "Invalid collation character"
+#~ msgstr "Nevalida kunfanda signo"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nevalida nomo de signoklaso"
+#~ msgid "Trailing backslash"
+#~ msgstr "Malsuprenstreko ĉe fino"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Malsuprenstreko ĉe fino"
+#~ msgid "Invalid back reference"
+#~ msgstr "Nevalida retroreferenco"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Nevalida retroreferenco"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Neparigita [ aÅ [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Neparigita [ aÅ [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Neparigita ( aÅ \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Neparigita ( aÅ \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Neparigita \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Neparigita \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Nevalida fino de gamo"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Nevalida enhavo de \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Mankas memoro"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Nevalida fino de gamo"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Nevalida antaÅa regula esprimo"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Mankas memoro"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Neatendita fino de regula esprimo"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Nevalida antaÅa regula esprimo"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Neparigita ) aÅ \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Neatendita fino de regula esprimo"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Regula esprimo tro granda"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Neparigita ) aÅ \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Mankas antaÅa regula esprimo"
+#~ msgid "No previous regular expression"
+#~ msgstr "Mankas antaÅa regula esprimo"
diff --git a/po/es.po b/po/es.po
index 250ad65..6f67017 100644
--- a/po/es.po
+++ b/po/es.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.8\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-10-24 12:38-0500\n"
"Last-Translator: Cristian Othón Martínez Vera \n"
"Language-Team: Spanish \n"
@@ -15,6 +15,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Opción desconocida para `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "error al leer de %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Carácter de nombre de clase inválido"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{' sin pareja"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Opción desconocida para `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Orden faltante"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Expresión regular demasiado grande"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "no hay soporte para la opción `e'"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Contenido inválido de \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -360,74 +560,47 @@ msgstr "error al leer de %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: no se puede leer %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Éxito"
+#~ msgid "Success"
+#~ msgstr "Éxito"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "No hay coincidencia"
+#~ msgid "No match"
+#~ msgstr "No hay coincidencia"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Expresion regular inválida"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Expresion regular inválida"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Carácter de ordenamiento inválido"
+#~ msgid "Invalid collation character"
+#~ msgstr "Carácter de ordenamiento inválido"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Carácter de nombre de clase inválido"
+#~ msgid "Trailing backslash"
+#~ msgstr "Diagonal invertida al final"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Diagonal invertida al final"
+#~ msgid "Invalid back reference"
+#~ msgstr "Referencia hacia atrás inválida"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Referencia hacia atrás inválida"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[ ó [^ sin pareja"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[ ó [^ sin pareja"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "( ó \\( sin pareja"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "( ó \\( sin pareja"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{ sin pareja"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{ sin pareja"
+#~ msgid "Invalid range end"
+#~ msgstr "Final de rango inválido"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Contenido inválido de \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Memoria agotada"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Final de rango inválido"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Expresión regular precedente inválida"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Memoria agotada"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Final prematuro de la expresión regular"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Expresión regular precedente inválida"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ") ó \\) sin pareja"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Final prematuro de la expresión regular"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Expresión regular demasiado grande"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ") ó \\) sin pareja"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "No hay una expresión regular previa"
+#~ msgid "No previous regular expression"
+#~ msgstr "No hay una expresión regular previa"
diff --git a/po/et.po b/po/et.po
index 0e11cd2..7d446ae 100644
--- a/po/et.po
+++ b/po/et.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.1.1\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-07-09 16:33+0300\n"
"Last-Translator: Toomas Soome \n"
"Language-Team: Estonian \n"
@@ -14,6 +14,206 @@ msgstr ""
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "tundmatu võti `s' käsule"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "lugemisviga %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Vigane sümbolite klassi nimi"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "liigne `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "tundmatu võti `s' käsule"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "käsk puudub"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Regulaaravaldis on liiga suur"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "võtit `e' ei toetata"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Vigane \\{\\} sisu"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr "korduv `!'"
@@ -363,74 +563,47 @@ msgstr "lugemisviga %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s ei saa ümber nimetada: %s"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Edukas"
+#~ msgid "Success"
+#~ msgstr "Edukas"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Ei leia"
+#~ msgid "No match"
+#~ msgstr "Ei leia"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Vigane regulaaravaldis"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Vigane regulaaravaldis"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Vigane sortimise sümbol"
+#~ msgid "Invalid collation character"
+#~ msgstr "Vigane sortimise sümbol"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Vigane sümbolite klassi nimi"
+#~ msgid "Trailing backslash"
+#~ msgstr "Lõpetav langkriips"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Lõpetav langkriips"
+#~ msgid "Invalid back reference"
+#~ msgstr "Vigane tagasi viide"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Vigane tagasi viide"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Puudub [ või [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Puudub [ või [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Puudub ( või \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Puudub ( või \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Puudub \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Puudub \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Vigane vahemiku lõpp"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Vigane \\{\\} sisu"
+#~ msgid "Memory exhausted"
+#~ msgstr "Mälu on otsas"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Vigane vahemiku lõpp"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Vigane eelnev regulaaravaldis"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Mälu on otsas"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Ootamatu regulaaravaldise lõpp"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Vigane eelnev regulaaravaldis"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Puudub ) või \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Ootamatu regulaaravaldise lõpp"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Regulaaravaldis on liiga suur"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Puudub ) või \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Eelmist regulaaravaldist pole"
+#~ msgid "No previous regular expression"
+#~ msgstr "Eelmist regulaaravaldist pole"
diff --git a/po/fi.po b/po/fi.po
index d63f3d3..b9b2ebf 100644
--- a/po/fi.po
+++ b/po/fi.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed-4.0.8\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-12-07 09:35+0200\n"
"Last-Translator: Sami J. Laine \n"
"Language-Team: Finnish \n"
@@ -15,6 +15,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Tuntematon valitsin \"s\":lle"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "lukuvirhe syötteessä %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Virhellinen merkkiluokan nimi"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Pariton \"{\""
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Tuntematon valitsin \"s\":lle"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Puuttuva komento"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Säännöllinen lauseke on liian suuri"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "valitsin `e' ei ole tuettu"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Virheellinen sisältö \\{\\}:ssä"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -360,74 +560,47 @@ msgstr "lukuvirhe sy
msgid "cannot rename %s: %s"
msgstr "%s: ei voida lukea syötettä %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Onnistui"
+#~ msgid "Success"
+#~ msgstr "Onnistui"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Ei osumaa"
+#~ msgid "No match"
+#~ msgstr "Ei osumaa"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Virheellinen säännöllinen lauseke"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Virheellinen säännöllinen lauseke"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Virheellinen vertailumerkki"
+#~ msgid "Invalid collation character"
+#~ msgstr "Virheellinen vertailumerkki"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Virhellinen merkkiluokan nimi"
+#~ msgid "Trailing backslash"
+#~ msgstr "Seuraava kenoviiva"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Seuraava kenoviiva"
+#~ msgid "Invalid back reference"
+#~ msgstr "Virheellinen takaisinviittaus"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Virheellinen takaisinviittaus"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Pariton \"[\" tai \"[^\""
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Pariton \"[\" tai \"[^\""
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Pariton \"(\" tai \"\\(\""
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Pariton \"(\" tai \"\\(\""
+#~ msgid "Unmatched \\{"
+#~ msgstr "Pariton \"\\{\""
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Pariton \"\\{\""
+#~ msgid "Invalid range end"
+#~ msgstr "Virheellinen välin loppu"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Virheellinen sisältö \\{\\}:ssä"
+#~ msgid "Memory exhausted"
+#~ msgstr "Muisti loppu"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Virheellinen välin loppu"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Virheellinen edeltävä säännöllinen lauseke"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Muisti loppu"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Ennenaikainen säännöllisen lausekkeen loppu"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Virheellinen edeltävä säännöllinen lauseke"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Pariton \")\" tai \"\\)\""
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Ennenaikainen säännöllisen lausekkeen loppu"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Säännöllinen lauseke on liian suuri"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Pariton \")\" tai \"\\)\""
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Ei aikaisempaa säännöllistä lausetta"
+#~ msgid "No previous regular expression"
+#~ msgstr "Ei aikaisempaa säännöllistä lausetta"
diff --git a/po/fr.po b/po/fr.po
index 8d53c8c..3df4914 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -9,7 +9,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.1.1\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-07-12 00:09+0200\n"
"Last-Translator: Gaël Quéri \n"
"Language-Team: French \n"
@@ -19,6 +19,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "option inconnue pour `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "erreur de lecture sur %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Nom de classe de caractères invalide"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{' non refermée"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "option inconnue pour `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "commande manquante"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Expression régulière trop grande"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "l'option `e' n'est pas supportée"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Contenu de \\{\\} invalide"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr "`!' multiples"
@@ -380,74 +580,47 @@ msgstr "erreur de lecture sur %s: %s"
msgid "cannot rename %s: %s"
msgstr "impossible de renommer %s: %s"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Succès"
+#~ msgid "Success"
+#~ msgstr "Succès"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Pas de concordance"
+#~ msgid "No match"
+#~ msgstr "Pas de concordance"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Expression régulière invalide"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Expression régulière invalide"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Caractère de collation invalide"
+#~ msgid "Invalid collation character"
+#~ msgstr "Caractère de collation invalide"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nom de classe de caractères invalide"
+#~ msgid "Trailing backslash"
+#~ msgstr "Antislash de protection"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Antislash de protection"
+#~ msgid "Invalid back reference"
+#~ msgstr "Référence arrière invalide"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Référence arrière invalide"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[ ou [^ non refermé"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[ ou [^ non refermé"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "( ou \\( non refermé"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "( ou \\( non refermé"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{ non refermé"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{ non refermé"
+#~ msgid "Invalid range end"
+#~ msgstr "Fin d'intervalle invalide"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Contenu de \\{\\} invalide"
+#~ msgid "Memory exhausted"
+#~ msgstr "Mémoire épuisée"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Fin d'intervalle invalide"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "L'expression régulière précédente est invalide"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Mémoire épuisée"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Fin prématurée d'une expression régulière"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "L'expression régulière précédente est invalide"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ") ou \\) non refermé"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Fin prématurée d'une expression régulière"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Expression régulière trop grande"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ") ou \\) non refermé"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Pas d'expression régulière précédente"
+#~ msgid "No previous regular expression"
+#~ msgstr "Pas d'expression régulière précédente"
diff --git a/po/ga.po b/po/ga.po
index 9b452bb..1f2dce0 100644
--- a/po/ga.po
+++ b/po/ga.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.1.1\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-07-07 11:04-0500\n"
"Last-Translator: Kevin Patrick Scannell \n"
"Language-Team: Irish \n"
@@ -15,6 +15,206 @@ msgstr ""
"Plural-Forms: nplurals=4; plural=n==1 ? 0 : (n>1 && n<7) ? 1 : (n>6 && n "
"<11) ? 2 : 3;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "rogha anaithnid i ndiaidh `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "earráid ag léamh %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Aicme charachtair neamhbhailí"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{' corr"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "rogha anaithnid i ndiaidh `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "ordú ar iarraidh"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Slonn ionadaíochta rómhór"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "níl an rogha `e' ar fáil"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Ábhar neamhbhailí idir \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr "`!'-anna iomadúla"
@@ -372,75 +572,48 @@ msgstr "earr
msgid "cannot rename %s: %s"
msgstr "ní féidir %s a athainmniú: %s"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Bua!"
+#~ msgid "Success"
+#~ msgstr "Bua!"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Níl a leithéid ann"
+#~ msgid "No match"
+#~ msgstr "Níl a leithéid ann"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Slonn ionadaíochta neamhbhailí"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Slonn ionadaíochta neamhbhailí"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Carachtar cóimheasa neamhbhailí"
+#~ msgid "Invalid collation character"
+#~ msgstr "Carachtar cóimheasa neamhbhailí"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Aicme charachtair neamhbhailí"
-
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Cúlslais ag deireadh"
+#~ msgid "Trailing backslash"
+#~ msgstr "Cúlslais ag deireadh"
# coinage - KPS
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Cúltagairt neamhbhailí"
+#~ msgid "Invalid back reference"
+#~ msgstr "Cúltagairt neamhbhailí"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[ nó [^ corr"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[ nó [^ corr"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "( nó \\( corr"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "( nó \\( corr"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{ corr"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{ corr"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Ábhar neamhbhailí idir \\{\\}"
+#~ msgid "Invalid range end"
+#~ msgstr "Deireadh raoin neamhbhailí"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Deireadh raoin neamhbhailí"
+#~ msgid "Memory exhausted"
+#~ msgstr "Cuimhne ídithe"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Cuimhne ídithe"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Is neamhbhailí an slonn ionadaíochta roimh seo"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Is neamhbhailí an slonn ionadaíochta roimh seo"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Deireadh le slonn ionadaíochta gan choinne"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Deireadh le slonn ionadaíochta gan choinne"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ") nó \\) corr"
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Slonn ionadaíochta rómhór"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ") nó \\) corr"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Níl aon slonn ionadaíochta roimh seo"
+#~ msgid "No previous regular expression"
+#~ msgstr "Níl aon slonn ionadaíochta roimh seo"
diff --git a/po/gl.po b/po/gl.po
index 8bfab43..f0f1003 100644
--- a/po/gl.po
+++ b/po/gl.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2002-10-25 15:57+0200\n"
"Last-Translator: Jacobo Tarrío Barreiro \n"
"Language-Team: Galician \n"
@@ -15,6 +15,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=n!=1;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Opción de `s' descoñecida"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "erro de lectura en %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Nome de clase de caracteres non válido"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{' sen parella"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Opción de `s' descoñecida"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Falta unha instrucción"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Expresión regular grande de máis"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "a opción `e' non está soportada"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Contido de \\{\\} non válido"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -360,74 +560,47 @@ msgstr "erro de lectura en %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: non se puido ler %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Éxito"
+#~ msgid "Success"
+#~ msgstr "Éxito"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Non se atopou"
+#~ msgid "No match"
+#~ msgstr "Non se atopou"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Expresión regular non válida"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Expresión regular non válida"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Carácter de ordeamento non válido"
+#~ msgid "Invalid collation character"
+#~ msgstr "Carácter de ordeamento non válido"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nome de clase de caracteres non válido"
+#~ msgid "Trailing backslash"
+#~ msgstr "Barra invertida á fin de liña"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Barra invertida á fin de liña"
+#~ msgid "Invalid back reference"
+#~ msgstr "Referencia cara a atrás non válida"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Referencia cara a atrás non válida"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[ ou [^ sen parella"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[ ou [^ sen parella"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "( ou \\( sen parella"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "( ou \\( sen parella"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{ sen parella"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{ sen parella"
+#~ msgid "Invalid range end"
+#~ msgstr "Fin de rango non válida"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Contido de \\{\\} non válido"
+#~ msgid "Memory exhausted"
+#~ msgstr "Memoria esgotada"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Fin de rango non válida"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Expresión regular anterior non válida"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Memoria esgotada"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Fin prematura da expresión regular"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Expresión regular anterior non válida"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ") ou \\) sen parella"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Fin prematura da expresión regular"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Expresión regular grande de máis"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ") ou \\) sen parella"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Non hai unha expresión regular anterior"
+#~ msgid "No previous regular expression"
+#~ msgstr "Non hai unha expresión regular anterior"
diff --git a/po/he.po b/po/he.po
index aa4771d..84b64fc 100644
--- a/po/he.po
+++ b/po/he.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 3.02.80\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2001-08-04 20:37+0300\n"
"Last-Translator: Eli Zaretskii \n"
"Language-Team: Hebrew \n"
@@ -14,6 +14,202 @@ msgstr ""
"Content-Transfer-Encoding: 8-bit\n"
"Report-Msgid-Bugs-To: \n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "`s' ìù øëåî-éúìá ïééôàî"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "%s úàéø÷á (%s) äì÷ú"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+msgid "invalid escape sequence in character class"
+msgstr ""
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "âåæ-ïá åì ïéàù `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "`s' ìù øëåî-éúìá ïééôàî"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "äøñç äãå÷ô"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+msgid "regular expression too large"
+msgstr ""
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+msgid "POSIX collating elements are not supported"
+msgstr ""
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+msgid "invalid repeat counts in {}"
+msgstr ""
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -346,78 +542,18 @@ msgstr "%s
msgid "cannot rename %s: %s"
msgstr "%s úéðëúá %s úàéø÷á (%s) äàéâù\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr ""
-
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr ""
-
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr ""
-
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr ""
-
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr ""
-
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr ""
-
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr ""
-
-#: lib/regcomp.c:171
#, fuzzy
-msgid "Unmatched [ or [^"
-msgstr "âåæ-ïá åì ïéàù `{'"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "âåæ-ïá åì ïéàù `{'"
-#: lib/regcomp.c:174
#, fuzzy
-msgid "Unmatched ( or \\("
-msgstr "âåæ-ïá åì ïéàù `{'"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "âåæ-ïá åì ïéàù `{'"
-#: lib/regcomp.c:177
#, fuzzy
-msgid "Unmatched \\{"
-msgstr "âåæ-ïá åì ïéàù `{'"
+#~ msgid "Unmatched \\{"
+#~ msgstr "âåæ-ïá åì ïéàù `{'"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr ""
-
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr ""
-
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr ""
-
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr ""
-
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr ""
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr ""
-
-#: lib/regcomp.c:198
#, fuzzy
-msgid "Unmatched ) or \\)"
-msgstr "âåæ-ïá åì ïéàù `{'"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr ""
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "âåæ-ïá åì ïéàù `{'"
diff --git a/po/hr.po b/po/hr.po
index 693c5ff..68d34be 100644
--- a/po/hr.po
+++ b/po/hr.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 3.02a\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2002-06-14 15:17-01\n"
"Last-Translator: Denis Lackovic \n"
"Language-Team: Croatian \n"
@@ -16,6 +16,203 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n==1?0:1);\n"
"X-Generator: TransDict server\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Nepoznata opcija za `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "Greška u �itanju na %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+msgid "invalid escape sequence in character class"
+msgstr ""
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Neuparena `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Nepoznata opcija za `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Nedostaje naredba"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Nedostaje prethodni regularni izraz"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+msgid "POSIX collating elements are not supported"
+msgstr ""
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+msgid "invalid repeat counts in {}"
+msgstr ""
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -350,82 +547,33 @@ msgstr "Greška u �itanju na %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: ne mogu �itati %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr ""
-
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr ""
-
-#: lib/regcomp.c:156
#, fuzzy
-msgid "Invalid regular expression"
-msgstr "Nedostaje prethodni regularni izraz"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Nedostaje prethodni regularni izraz"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr ""
-
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr ""
-
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr ""
-
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr ""
-
-#: lib/regcomp.c:171
#, fuzzy
-msgid "Unmatched [ or [^"
-msgstr "Neuparena `{'"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Neuparena `{'"
-#: lib/regcomp.c:174
#, fuzzy
-msgid "Unmatched ( or \\("
-msgstr "Neuparena `{'"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Neuparena `{'"
-#: lib/regcomp.c:177
#, fuzzy
-msgid "Unmatched \\{"
-msgstr "Neuparena `{'"
+#~ msgid "Unmatched \\{"
+#~ msgstr "Neuparena `{'"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr ""
-
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr ""
-
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr ""
-
-#: lib/regcomp.c:189
#, fuzzy
-msgid "Invalid preceding regular expression"
-msgstr "Nedostaje prethodni regularni izraz"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Nedostaje prethodni regularni izraz"
-#: lib/regcomp.c:192
#, fuzzy
-msgid "Premature end of regular expression"
-msgstr "Nedostaje prethodni regularni izraz"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Nedostaje prethodni regularni izraz"
-#: lib/regcomp.c:195
#, fuzzy
-msgid "Regular expression too big"
-msgstr "Nedostaje prethodni regularni izraz"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Neuparena `{'"
-#: lib/regcomp.c:198
-#, fuzzy
-msgid "Unmatched ) or \\)"
-msgstr "Neuparena `{'"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Nedostaje prethodni regularni izraz"
+#~ msgid "No previous regular expression"
+#~ msgstr "Nedostaje prethodni regularni izraz"
diff --git a/po/hu.po b/po/hu.po
index ff703af..56b453e 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.8\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-10-26 09:28+0100\n"
"Last-Translator: Mihály Gyulai \n"
"Language-Team: Hungarian \n"
@@ -15,6 +15,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Ismeretlen `s' opció"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "olvasási hiba %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Érvénytelen karakterosztály-név"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Nincs párban `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Ismeretlen `s' opció"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Hiányzó parancs"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Túl nagy reguláris kifejezés"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "az `e' opció nincs támogatva"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "\\{\\}-nak érvénytelen a tartalma"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -358,74 +558,47 @@ msgstr "olvas
msgid "cannot rename %s: %s"
msgstr "%s: nem lehet olvasni %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Sikeres"
+#~ msgid "Success"
+#~ msgstr "Sikeres"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Nincs találat"
+#~ msgid "No match"
+#~ msgstr "Nincs találat"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Hibás reguláris kifejezés"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Hibás reguláris kifejezés"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Érvénytelen összehasonlító karakter"
+#~ msgid "Invalid collation character"
+#~ msgstr "Érvénytelen összehasonlító karakter"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Érvénytelen karakterosztály-név"
+#~ msgid "Trailing backslash"
+#~ msgstr "Lezáró visszaperjel"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Lezáró visszaperjel"
+#~ msgid "Invalid back reference"
+#~ msgstr "Érvénytelen vissza-hivatkozás"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Érvénytelen vissza-hivatkozás"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Nincs párban [ vagy [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Nincs párban [ vagy [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Nincs párban ( vagy \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Nincs párban ( vagy \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Nincs párban \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Nincs párban \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Sorozat érvénytelen vége"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "\\{\\}-nak érvénytelen a tartalma"
+#~ msgid "Memory exhausted"
+#~ msgstr "Kevés a memória"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Sorozat érvénytelen vége"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Érvénytelen megelõzõ reguláris kifejezés"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Kevés a memória"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Reguláris kifejezés túl korai vége"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Érvénytelen megelõzõ reguláris kifejezés"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Nincs párban ) vagy \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Reguláris kifejezés túl korai vége"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Túl nagy reguláris kifejezés"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Nincs párban ) vagy \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Nincsen elõzõ reguláris kifejezés"
+#~ msgid "No previous regular expression"
+#~ msgstr "Nincsen elõzõ reguláris kifejezés"
diff --git a/po/id.po b/po/id.po
index e1e8fae..bd533e1 100644
--- a/po/id.po
+++ b/po/id.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.9\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-04-27 14:56+0700\n"
"Last-Translator: Tedi Heriyanto \n"
"Language-Team: Indonesian \n"
@@ -16,6 +16,206 @@ msgstr ""
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: KBabel 1.3\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Opsion tidak dikenal bagi `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "kesalahan pembacaan pada %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Nama kelas karakter tidak valid"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{' tidak sesuai"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Opsion tidak dikenal bagi `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Perintah hilang"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Reguler ekspresi terlalu besar"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "option `e' tidak didukung"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Isi \\{\\} tidak valid"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -358,74 +558,47 @@ msgstr "kesalahan pembacaan pada %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: tidak dapat membaca %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Sukses"
+#~ msgid "Success"
+#~ msgstr "Sukses"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Tidak cocok"
+#~ msgid "No match"
+#~ msgstr "Tidak cocok"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Reguler ekspresi tidak valid"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Reguler ekspresi tidak valid"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Karakter kolasi tidak valid"
+#~ msgid "Invalid collation character"
+#~ msgstr "Karakter kolasi tidak valid"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nama kelas karakter tidak valid"
+#~ msgid "Trailing backslash"
+#~ msgstr "Trailing backslash"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Trailing backslash"
+#~ msgid "Invalid back reference"
+#~ msgstr "Referensi balik tidak valid"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Referensi balik tidak valid"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[ atau [^ tidak sesuai"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[ atau [^ tidak sesuai"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "( atau \\( tidak sesuai"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "( atau \\( tidak sesuai"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{ tidak sesuai"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{ tidak sesuai"
+#~ msgid "Invalid range end"
+#~ msgstr "Akhir batas tidak valid"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Isi \\{\\} tidak valid"
+#~ msgid "Memory exhausted"
+#~ msgstr "Memori habis"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Akhir batas tidak valid"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Reguler ekspresi sebelumnya tidak valid"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Memori habis"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Akhir reguler ekspresi prematur"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Reguler ekspresi sebelumnya tidak valid"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ") atau \\) tidak sesuai"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Akhir reguler ekspresi prematur"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Reguler ekspresi terlalu besar"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ") atau \\) tidak sesuai"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Tidak ada reguler ekspresi sebelumnya"
+#~ msgid "No previous regular expression"
+#~ msgstr "Tidak ada reguler ekspresi sebelumnya"
diff --git a/po/it.po b/po/it.po
index 0742b5d..3f76ae9 100644
--- a/po/it.po
+++ b/po/it.po
@@ -1,124 +1,291 @@
-# traduzione di sed
-# Copyright (C) 1999 Free Software Foundation, Inc.
-# Paolo Bonzini , 2001
-#
msgid ""
msgstr ""
-"Project-Id-Version: sed 4.0a\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
-"PO-Revision-Date: 2002-11-26 12:44+0100\n"
+"Project-Id-Version: ssed 3.46\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
+"PO-Revision-Date: 2000-12-21 12:44+0100\n"
"Last-Translator: Paolo Bonzini \n"
-"Language-Team: Italian \n"
+"Language-Team: Italian \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8-bit\n"
-"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-# sed/compile.c:166
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr "Utilizzo: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+
+#: pcre/pcregrep.c:212
+#, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "pcregrep: opzione %c sconosciuta\n"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr "pcregrep: errore nell'espressione alla posizione %d: %s\n"
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr "pcregrep: errore nell'analisi dell'espressione: %s\n"
+
+#: pcre/pcregrep.c:268
+#, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "pcregrep: impossibile aprire %s: %s\n"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr "\\ alla fine dell'espressione"
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr "\\c alla fine dell'espressione"
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr "carattere non riconosciuto dopo \\"
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr "i numeri dentro le graffe non sono in ordine"
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr "un numero dentro le graffe e' troppo grande"
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr "manca una quadra chiusa"
+
+#: pcre/regexp.c:54
+msgid "invalid escape sequence in character class"
+msgstr "sequenza di escape non valida tra parentesi quadre"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr "intervallo di caratteri non valido tra parentesi quadre"
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr "operatore di ripetizione al posto sbagliato"
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr "un atomo ripetibile indefinitamente potrebbe essere vuoto"
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr "errore interno: comando di ripetizione inatteso"
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr "carattere non riconosciuto dopo (?"
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr "errore inutilizzato"
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+msgid "unmatched braces"
+msgstr "manca una graffa chiusa"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr "riferimento all'indietro non valido (subpattern inesistente)"
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr "il parametro erroffset e' NULL"
+
+#: pcre/regexp.c:64
+msgid "unknown option bit(s) set"
+msgstr "sono impostati dei bit di opzione sconosciuti"
+
+#: pcre/regexp.c:65
+msgid "missing ) after comment"
+msgstr "manca una parentesi di chiusura di un commento"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr "parentesi troppo annidate"
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+msgid "regular expression too large"
+msgstr "espressione troppo grande"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr "memoria esaurita"
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr "manca una parentesi chiusa"
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr "errore interno di compilazione"
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr "carattere non riconosciuto dopo (?<"
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr "i controlli all'indietro devono avere lunghezza fissa"
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr "numero non valido dopo (?("
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr "piu' di due divisioni in un gruppo condizionale"
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr "atteso numero associato a una condizione dopo (?("
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr "(?p non seguito da )"
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr "nome POSIX di classe di caratteri sconosciuto"
+
+#: pcre/regexp.c:78
+msgid "POSIX collating elements are not supported"
+msgstr "le specifiche di caratteri speciali non sono supportate"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr "condizione (?(0) non valida"
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr "errore interno"
+
+#: pcre/regexp.c:126
+msgid "invalid repeat counts in {}"
+msgstr "numero di ripetizioni specificato tra graffe non valido"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr "errore nell'espressione regolare"
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr "specifica di caratteri speciali non valida"
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr "sequenza di escape non valida"
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr "l'espressione regolare non e' valida"
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr "argomento non valido"
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr "espressione non trovata"
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr "errore sconosciuto"
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr "%s alla posizione %-6d"
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr "`!' multipli"
-# sed/compile.c:167
#: sed/compile.c:163
msgid "unexpected `,'"
msgstr "`,' inattesa"
-# sed/compile.c:169
#: sed/compile.c:164
msgid "invalid usage of +N or ~N as first address"
-msgstr "impossibile usare +N o ~N come primo indirizzo"
+msgstr "Impossibile usare +N o ~N come primo indirizzo"
-# sed/compile.c:170
#: sed/compile.c:165
msgid "unmatched `{'"
msgstr "`{' non bilanciata"
-# sed/compile.c:171
#: sed/compile.c:166
msgid "unexpected `}'"
msgstr "`}' inattesa"
-# sed/compile.c:172
#: sed/compile.c:167
msgid "extra characters after command"
msgstr "ci sono altri caratteri dopo il comando"
-# sed/compile.c:173
#: sed/compile.c:168
msgid "expected \\ after `a', `c' or `i'"
msgstr "atteso \\ dopo `a', `c' o `i'"
-# sed/compile.c:174
#: sed/compile.c:169
msgid "`}' doesn't want any addresses"
msgstr "`}' non accetta indirizzi"
-# sed/compile.c:175
#: sed/compile.c:170
msgid ": doesn't want any addresses"
msgstr ": non accetta indirizzi"
-# sed/compile.c:176
#: sed/compile.c:171
msgid "comments don't accept any addresses"
msgstr "i commenti non accettano indirizzi"
-# sed/compile.c:177
#: sed/compile.c:172
msgid "missing command"
msgstr "manca il comando"
-# sed/compile.c:178
#: sed/compile.c:173
msgid "command only uses one address"
msgstr "il comando usa solo un indirizzo"
-# sed/compile.c:179
#: sed/compile.c:174
msgid "unterminated address regex"
-msgstr "espressione regolare non terminata nell'indirizzo"
+msgstr "indirizzo della regex non terminato"
-# sed/compile.c:180
#: sed/compile.c:175
msgid "unterminated `s' command"
msgstr "comando `s' non terminato"
-# sed/compile.c:181
#: sed/compile.c:176
msgid "unterminated `y' command"
msgstr "comando `y' non terminato"
-# sed/compile.c:182
#: sed/compile.c:177
msgid "unknown option to `s'"
msgstr "opzione di `s' sconosciuta"
-# sed/compile.c:183
#: sed/compile.c:178
msgid "multiple `p' options to `s' command"
msgstr "opzioni `p' multiple al comando `s'"
-# sed/compile.c:184
#: sed/compile.c:179
msgid "multiple `g' options to `s' command"
msgstr "opzioni `g' multiple al comando `s'"
-# sed/compile.c:186
#: sed/compile.c:180
msgid "multiple number options to `s' command"
msgstr "opzioni numeriche multiple al comando `s'"
-# sed/compile.c:188
#: sed/compile.c:181
msgid "number option to `s' command may not be zero"
msgstr "l'opzione numerica del comando `s' non può essere zero"
-# sed/compile.c:190
#: sed/compile.c:182
msgid "strings for `y' command are different lengths"
-msgstr "le stringhe per il comandi `y' hanno lunghezze diverse"
+msgstr "le stringhe per i comandi `y' hanno lunghezze diverse"
#: sed/compile.c:183
msgid "delimiter character is not a single-byte character"
@@ -128,90 +295,75 @@ msgstr "il carattere delimitatore
msgid "expected newer version of sed"
msgstr "attesa una versione piu' recente di sed"
-# sed/compile.c:178
#: sed/compile.c:185
msgid "invalid usage of line address 0"
-msgstr "utilizzo non valido dell'indirizzo 0"
+msgstr "uso non valido della linea 0"
-# sed/compile.c:1319
#: sed/compile.c:186
#, c-format
msgid "unknown command: `%c'"
msgstr "comando sconosciuto: `%c'"
-# sed/compile.c:1340
#: sed/compile.c:209
#, c-format
msgid "%s: file %s line %lu: %s\n"
msgstr "%s: file %s riga %lu: %s\n"
-# sed/compile.c:1343
#: sed/compile.c:212
#, c-format
msgid "%s: -e expression #%lu, char %lu: %s\n"
msgstr "%s: espressione -e #%lu, carattere %lu: %s\n"
-# sed/compile.c:1543
#: sed/compile.c:1644
#, c-format
msgid "can't find label for jump to `%s'"
msgstr "impossibile trovare un'etichetta per il salto a `%s'"
-# sed/execute.c:516
#: sed/execute.c:649
#, c-format
msgid "%s: can't read %s: %s\n"
msgstr "%s: impossibile leggere %s: %s\n"
-# sed/execute.c:675
#: sed/execute.c:672
#, c-format
msgid "couldn't edit %s: is a terminal"
-msgstr "impossibile modificare %s: è un terminale"
+msgstr "impossibile modificare il file %s: è un terminale"
#: sed/execute.c:676
#, c-format
msgid "couldn't edit %s: not a regular file"
-msgstr "impossibile modificare %s: non è un file normale"
+msgstr "impossibile modificare il file %s: non è un file regolare"
-# lib/utils.c:131
#: sed/execute.c:683 lib/utils.c:196
#, c-format
msgid "couldn't open temporary file %s: %s"
msgstr "impossibile aprire il file temporaneo %s: %s"
-# sed/execute.c:1003 sed/execute.c:1183
#: sed/execute.c:1207 sed/execute.c:1388
msgid "error in subprocess"
msgstr "errore in un sottoprocesso"
-# sed/execute.c:1005
#: sed/execute.c:1209
msgid "option `e' not supported"
msgstr "opzione `e' non supportata"
-# sed/execute.c:1185
#: sed/execute.c:1390
msgid "`e' command not supported"
msgstr "comando `e' non supportato"
-# lib/regcomp.c:658 sed/regex.c:47
#: sed/regexp.c:39
msgid "no previous regular expression"
msgstr "occorre un'espressione regolare precedente"
-# sed/regex.c:48
#: sed/regexp.c:40
msgid "cannot specify modifiers on empty regexp"
msgstr "non è possibile specificare dei modificatori per l'espressione vuota"
-# sed/regex.c:146
#: sed/regexp.c:134
#, c-format
msgid "invalid reference \\%d on `s' command's RHS"
msgstr "riferimento non valido \\%d nel secondo membro del comando `s'"
-# sed/sed.c:98
#: sed/sed.c:96
msgid ""
" -R, --regexp-perl\n"
@@ -282,7 +434,6 @@ msgstr ""
" --posix\n"
" disabilita tutte le estensioni GNU.\n"
-# sed/sed.c:98
#: sed/sed.c:117
msgid ""
" -r, --regexp-extended\n"
@@ -338,7 +489,6 @@ msgstr ""
"sono specificati file di input sarà letto lo standard input.\n"
"\n"
-# sed/sed.c:132
#: sed/sed.c:134
#, c-format
msgid ""
@@ -348,13 +498,11 @@ msgstr ""
"Segnalare eventuali bug a: %s .\n"
"Assicurarsi di includere la parola ``%s'' nell'oggetto del messaggio.\n"
-# sed/sed.c:255
#: sed/sed.c:271
#, c-format
msgid "super-sed version %s\n"
msgstr "super-sed versione %s\n"
-# sed/sed.c:256
#: sed/sed.c:272
#, c-format
msgid ""
@@ -364,13 +512,11 @@ msgstr ""
"basato su GNU sed versione %s\n"
"\n"
-# sed/sed.c:258
#: sed/sed.c:274
#, c-format
msgid "GNU sed version %s\n"
msgstr "GNU sed versione %s\n"
-# sed/sed.c:260
#: sed/sed.c:276
#, c-format
msgid ""
@@ -385,124 +531,29 @@ msgstr ""
"NON c'è garanzia; neppure di COMMERCIABILITA' o IDONEITA' AD UN PARTICOLARE\n"
"SCOPO, nei limiti permessi dalla legge.\n"
-# sed/execute.c:516
#: lib/utils.c:98 lib/utils.c:336
#, c-format
msgid "cannot remove %s: %s"
-msgstr "impossibile rimuovere %s: %s"
+msgstr "impossibile eliminare %s: %s"
-# lib/utils.c:131
#: lib/utils.c:143
#, c-format
msgid "couldn't open file %s: %s"
msgstr "impossibile aprire il file %s: %s"
-# lib/utils.c:161
#: lib/utils.c:220
#, c-format
msgid "couldn't write %d item to %s: %s"
msgid_plural "couldn't write %d items to %s: %s"
-msgstr[0] "Impossibile scrivere %d elemento su %s: %s"
-msgstr[1] "Impossibile scrivere %d elementi su %s: %s"
+msgstr[0] "impossibile scrivere %d elemento su %s: %s"
+msgstr[1] "impossibile scrivere %d elementi su %s: %s"
-# lib/utils.c:176
#: lib/utils.c:235 lib/utils.c:251
#, c-format
msgid "read error on %s: %s"
msgstr "errore di lettura su %s: %s"
-# sed/execute.c:516
#: lib/utils.c:341
#, c-format
msgid "cannot rename %s: %s"
msgstr "impossibile rinominare %s: %s"
-
-# lib/regcomp.c:179
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Successo"
-
-# lib/regcomp.c:182
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Nessuna corrispondenza trovata"
-
-# lib/regcomp.c:185
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Espressione regolare non valida"
-
-# lib/regcomp.c:188
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Carattere di ordinamento non valido"
-
-# lib/regcomp.c:191
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nome non valido per una classe di caratteri"
-
-# lib/regcomp.c:194
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Barra rovesciata alla fine dell'espressione regolare"
-
-# lib/regcomp.c:197
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Riferimento non valido"
-
-# lib/regcomp.c:200
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "`[' non bilanciata"
-
-# lib/regcomp.c:203
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "`(' o `\\(' non bilanciata"
-
-# lib/regcomp.c:206
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "`\\{' non bilanciata"
-
-# lib/regcomp.c:209
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "numero di ripetizioni specificato tra graffe non valido"
-
-# lib/regcomp.c:212
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Fine dell'intervallo non valida"
-
-# lib/regcomp.c:215
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Memoria esaurita"
-
-# lib/regcomp.c:218
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Espressione regolare precedente non valida"
-
-# lib/regcomp.c:221
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Fine prematura dell'espressione regolare"
-
-# lib/regcomp.c:224
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Espressione regolare troppo grande"
-
-# lib/regcomp.c:227
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "`)' o `\\)' non bilanciata"
-
-# lib/regcomp.c:658 sed/regex.c:47
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Occorre un'espressione regolare precedente"
diff --git a/po/ja.po b/po/ja.po
index 47205b2..41ab69a 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -9,7 +9,7 @@
msgid ""
msgstr ""
"Project-Id-Version: GNU sed 4.0.6\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-04-21 23:53+0900\n"
"Last-Translator: IIDA Yosiaki \n"
"Language-Team: Japanese \n"
@@ -19,6 +19,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "`s'¤Ø¤Î¥ª¥×¥·¥ç¥ó¤¬ÉÔÌÀ¤Ç¤¹"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "%s¤ÎÆÉ¹þ¤ß¥¨¥é¡¼: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "̵¸ú¤Êʸ»ú¥¯¥é¥¹Ì¾"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{'¤¬Äà¹ç¤¤¤Þ¤»¤ó"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "`s'¤Ø¤Î¥ª¥×¥·¥ç¥ó¤¬ÉÔÌÀ¤Ç¤¹"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "¥³¥Þ¥ó¥É¤¬Â¤ê¤Þ¤»¤ó"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Â礲᤮¤ëÀµµ¬É½¸½"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "e¥ª¥×¥·¥ç¥ó¤Ï¡¢¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤»¤ó"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "̵¸ú¤Ê\\{\\}¤ÎÆâÍÆ\""
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -371,74 +571,47 @@ msgstr "%s
msgid "cannot rename %s: %s"
msgstr "%s: %s¤òÆÉ¤ß¹þ¤á¤Þ¤»¤ó: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "À®¸ù"
+#~ msgid "Success"
+#~ msgstr "À®¸ù"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "¾È¹ç¤·¤Þ¤»¤ó"
+#~ msgid "No match"
+#~ msgstr "¾È¹ç¤·¤Þ¤»¤ó"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "̵¸ú¤ÊÀµµ¬É½¸½"
+#~ msgid "Invalid regular expression"
+#~ msgstr "̵¸ú¤ÊÀµµ¬É½¸½"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "̵¸ú¤Ê¹»¹çʸ»ú"
+#~ msgid "Invalid collation character"
+#~ msgstr "̵¸ú¤Ê¹»¹çʸ»ú"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "̵¸ú¤Êʸ»ú¥¯¥é¥¹Ì¾"
+#~ msgid "Trailing backslash"
+#~ msgstr "¸å³¤ÎµÕ¥¹¥é¥Ã¥·¥å"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "¸å³¤ÎµÕ¥¹¥é¥Ã¥·¥å"
+#~ msgid "Invalid back reference"
+#~ msgstr "̵¸ú¤ÊµÕ»²¾È"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "̵¸ú¤ÊµÕ»²¾È"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[¤ä[^¤¬Äà¹ç¤¤¤Þ¤»¤ó"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[¤ä[^¤¬Äà¹ç¤¤¤Þ¤»¤ó"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "(¤ä\\(¤¬Äà¹ç¤¤¤Þ¤»¤ó"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "(¤ä\\(¤¬Äà¹ç¤¤¤Þ¤»¤ó"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{¤¬Äà¹ç¤¤¤Þ¤»¤ó"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{¤¬Äà¹ç¤¤¤Þ¤»¤ó"
+#~ msgid "Invalid range end"
+#~ msgstr "̵¸ú¤ÊÈϰϤνªÃ¼"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "̵¸ú¤Ê\\{\\}¤ÎÆâÍÆ\""
+#~ msgid "Memory exhausted"
+#~ msgstr "¥á¥â¥ê¡¼¤¬Â¤ê¤Þ¤»¤ó"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "̵¸ú¤ÊÈϰϤνªÃ¼"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "̵¸ú¤ÊÀè¹ÔÀµµ¬É½¸½"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "¥á¥â¥ê¡¼¤¬Â¤ê¤Þ¤»¤ó"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "ͽ´ü¤»¤ÌÀµµ¬É½¸½¤Î½ªÃ¼"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "̵¸ú¤ÊÀè¹ÔÀµµ¬É½¸½"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ")¤ä\\)¤¬°ìÃפ·¤Þ¤»¤ó"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "ͽ´ü¤»¤ÌÀµµ¬É½¸½¤Î½ªÃ¼"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Â礲᤮¤ëÀµµ¬É½¸½"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ")¤ä\\)¤¬°ìÃפ·¤Þ¤»¤ó"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "ľÁ°¤ÎÀµµ¬É½¸½¤¬¡¢¤¢¤ê¤Þ¤»¤ó"
+#~ msgid "No previous regular expression"
+#~ msgstr "ľÁ°¤ÎÀµµ¬É½¸½¤¬¡¢¤¢¤ê¤Þ¤»¤ó"
diff --git a/po/ko.po b/po/ko.po
index 81c12a4..05fcfa9 100644
--- a/po/ko.po
+++ b/po/ko.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: GNU sed 3.02.80\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2001-10-12 17:26+0900\n"
"Last-Translator: Jong-Hoon Ryu \n"
"Language-Team: Korean \n"
@@ -14,6 +14,202 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Report-Msgid-Bugs-To: \n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "`s' ¿¡ ¾Ë ¼ö ¾ø´Â ¿É¼ÇÀÌ ÀÖ½À´Ï´Ù"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "%s ÀÇ ³»¿ë Àб⠿À·ù: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+msgid "invalid escape sequence in character class"
+msgstr ""
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "`s' ¿¡ ¾Ë ¼ö ¾ø´Â ¿É¼ÇÀÌ ÀÖ½À´Ï´Ù"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "¸í·ÉÀÌ ÁöÁ¤µÇÁö ¾Ê¾Ò½À´Ï´Ù"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+msgid "regular expression too large"
+msgstr ""
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+msgid "POSIX collating elements are not supported"
+msgstr ""
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+msgid "invalid repeat counts in {}"
+msgstr ""
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -346,78 +542,18 @@ msgstr "%s
msgid "cannot rename %s: %s"
msgstr "%s: %s (À»)¸¦ ÀÐÀ» ¼ö ¾øÀ½: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr ""
-
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr ""
-
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr ""
-
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr ""
-
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr ""
-
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr ""
-
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr ""
-
-#: lib/regcomp.c:171
#, fuzzy
-msgid "Unmatched [ or [^"
-msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
-#: lib/regcomp.c:174
#, fuzzy
-msgid "Unmatched ( or \\("
-msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
-#: lib/regcomp.c:177
#, fuzzy
-msgid "Unmatched \\{"
-msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
+#~ msgid "Unmatched \\{"
+#~ msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr ""
-
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr ""
-
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr ""
-
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr ""
-
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr ""
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr ""
-
-#: lib/regcomp.c:198
#, fuzzy
-msgid "Unmatched ) or \\)"
-msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr ""
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "`{' °¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù"
diff --git a/po/nl.po b/po/nl.po
index 3277524..7a3ac0a 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.9\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-04-09 21:39+0200\n"
"Last-Translator: Elros Cyriatan \n"
"Language-Team: Dutch \n"
@@ -17,6 +17,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Onbekende optie voor `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "leesfout op %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Ongeldige tekenklasse naam"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Niet-overeenkomende `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Onbekende optie voor `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Ontbrekende opdracht"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Reguliere uitdrukking te groot"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "optie `e' niet ondersteund"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Ongeldige inhoud van \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -362,74 +562,47 @@ msgstr "leesfout op %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: kan %s niet lezen: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Succes"
+#~ msgid "Success"
+#~ msgstr "Succes"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Geen overeenkomst"
+#~ msgid "No match"
+#~ msgstr "Geen overeenkomst"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Ongeldige reguliere uitdrukking"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Ongeldige reguliere uitdrukking"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Ongeldig sorteerteken"
+#~ msgid "Invalid collation character"
+#~ msgstr "Ongeldig sorteerteken"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Ongeldige tekenklasse naam"
+#~ msgid "Trailing backslash"
+#~ msgstr "Backslash aan het einde"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Backslash aan het einde"
+#~ msgid "Invalid back reference"
+#~ msgstr "Ongeldige terugverwijzing"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Ongeldige terugverwijzing"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Niet-overeenkomende [ of [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Niet-overeenkomende [ of [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Niet-overeenkomende ( of \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Niet-overeenkomende ( of \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Niet-overeenkomende \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Niet-overeenkomende \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Ongeldig bereikeinde"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Ongeldige inhoud van \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Geheugen uitgeput"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Ongeldig bereikeinde"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Ongeldige voorafgaande reguliere uitdrukking"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Geheugen uitgeput"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Vroegtijdig einde van reguliere uitdrukking"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Ongeldige voorafgaande reguliere uitdrukking"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Niet-overeenkomende ) of \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Vroegtijdig einde van reguliere uitdrukking"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Reguliere uitdrukking te groot"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Niet-overeenkomende ) of \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Geen eerdere reguliere uitdrukking"
+#~ msgid "No previous regular expression"
+#~ msgstr "Geen eerdere reguliere uitdrukking"
diff --git a/po/pl.po b/po/pl.po
index 273ef35..3988d1a 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.1.1\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-07-08 19:58+0200\n"
"Last-Translator: Wojciech Polak \n"
"Language-Team: Polish \n"
@@ -16,6 +16,206 @@ msgstr ""
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "nieznana opcja dla polecenia `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "b³±d odczytu w %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Nieprawid³owa nazwa klasy znaku"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "niedopasowany znak `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "nieznana opcja dla polecenia `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "brakuje polecenia"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Wyra¿enie regularne jest zbyt du¿e"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "opcja `e' nie jest wspierana"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Nieprawid³owa zawarto¶æ \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr "wielokrotny znak `!'"
@@ -372,74 +572,47 @@ msgstr "b
msgid "cannot rename %s: %s"
msgstr "nie mo¿na zmieniæ nazwy %s: %s"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Sukces"
+#~ msgid "Success"
+#~ msgstr "Sukces"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Brak dopasowania"
+#~ msgid "No match"
+#~ msgstr "Brak dopasowania"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Nieprawid³owe wyra¿enie regularne"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Nieprawid³owe wyra¿enie regularne"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Nieprawid³owy znak porównania"
+#~ msgid "Invalid collation character"
+#~ msgstr "Nieprawid³owy znak porównania"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nieprawid³owa nazwa klasy znaku"
+#~ msgid "Trailing backslash"
+#~ msgstr "Koñcowy znak backslash"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Koñcowy znak backslash"
+#~ msgid "Invalid back reference"
+#~ msgstr "Nieprawid³owe odwo³anie wsteczne"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Nieprawid³owe odwo³anie wsteczne"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Niedopasowany znak [ lub [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Niedopasowany znak [ lub [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Niedopasowany znak ( lub \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Niedopasowany znak ( lub \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Niedopasowany znak \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Niedopasowany znak \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Nieprawid³owy koniec zakresu"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Nieprawid³owa zawarto¶æ \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Pamiêæ wyczerpana"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Nieprawid³owy koniec zakresu"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Nieprawid³owe poprzedzaj±ce wyra¿enie regularne"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Pamiêæ wyczerpana"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Przedwczesny koniec wyra¿enia regularnego"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Nieprawid³owe poprzedzaj±ce wyra¿enie regularne"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Niedopasowany znak ) lub \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Przedwczesny koniec wyra¿enia regularnego"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Wyra¿enie regularne jest zbyt du¿e"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Niedopasowany znak ) lub \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Brak poprzedniego wyra¿enia regularnego"
+#~ msgid "No previous regular expression"
+#~ msgstr "Brak poprzedniego wyra¿enia regularnego"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index b9b037d..4f48cf2 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -8,7 +8,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.1\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2002-11-08 17:44-0300\n"
"Last-Translator: Aurélio Marinho Jargas \n"
"Language-Team: Brazilian Portuguese \n"
@@ -18,6 +18,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Opção desconhecida para o comando `s' (s///?)"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "erro de leitura em %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Nome inválido de classe de caracteres"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{' não terminada"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Opção desconhecida para o comando `s' (s///?)"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Falta especificar um comando ao endereço"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Expressão regular grande demais"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "opção `e' não suportada"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Conteúdo inválido no \\{\\} (permitidos números e vírgula)"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -360,74 +560,47 @@ msgstr "erro de leitura em %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: não foi possível ler %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Sucesso"
+#~ msgid "Success"
+#~ msgstr "Sucesso"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Nada encontrado"
+#~ msgid "No match"
+#~ msgstr "Nada encontrado"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Expressão regular inválida"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Expressão regular inválida"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Caractere de ordenação inválido"
+#~ msgid "Invalid collation character"
+#~ msgstr "Caractere de ordenação inválido"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nome inválido de classe de caracteres"
+#~ msgid "Trailing backslash"
+#~ msgstr "Escape \\ no final"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Escape \\ no final"
+#~ msgid "Invalid back reference"
+#~ msgstr "Retrovisor \\n inválido"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Retrovisor \\n inválido"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[ ou [^ não terminado"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[ ou [^ não terminado"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "( ou \\( não terminado"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "( ou \\( não terminado"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{ não terminado"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{ não terminado"
+#~ msgid "Invalid range end"
+#~ msgstr "Fim de intervalo (range) inválido"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Conteúdo inválido no \\{\\} (permitidos números e vírgula)"
+#~ msgid "Memory exhausted"
+#~ msgstr "Falta de memória"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Fim de intervalo (range) inválido"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Expressão regular anterior inválida"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Falta de memória"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Fim prematuro da expressão regular"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Expressão regular anterior inválida"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ") or \\) inesperado"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Fim prematuro da expressão regular"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Expressão regular grande demais"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ") or \\) inesperado"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Não há expressão regular anterior"
+#~ msgid "No previous regular expression"
+#~ msgstr "Não há expressão regular anterior"
diff --git a/po/ro.po b/po/ro.po
index 024f14e..bf01c26 100644
--- a/po/ro.po
+++ b/po/ro.po
@@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.8\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-11-22 12:00-0500\n"
"Last-Translator: Laurentiu Buzdugan \n"
"Language-Team: Romanian \n"
@@ -17,6 +17,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Opþiune necunoscutã pentru `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "eroare citire pentru %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Nume de clasã de caractere incorect"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "`{' fãrã pereche"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Opþiune necunoscutã pentru `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Comandã absentã"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Expresie regularã prea mare"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "opþiunea `e' nu e suportatã"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Conþinut incorect pentru \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -362,74 +562,47 @@ msgstr "eroare citire pentru %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: nu pot citi %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Succes"
+#~ msgid "Success"
+#~ msgstr "Succes"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Nici o potrivire"
+#~ msgid "No match"
+#~ msgstr "Nici o potrivire"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Expresie regularã incorectã"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Expresie regularã incorectã"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Colaþiune de caractere incorectã"
+#~ msgid "Invalid collation character"
+#~ msgstr "Colaþiune de caractere incorectã"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Nume de clasã de caractere incorect"
+#~ msgid "Trailing backslash"
+#~ msgstr "Backslash în coadã"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Backslash în coadã"
+#~ msgid "Invalid back reference"
+#~ msgstr "Referinþã înapoi incorectã"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Referinþã înapoi incorectã"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "[ sau [^ fãrã pereche"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "[ sau [^ fãrã pereche"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "( sau \\( fãrã pereche"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "( sau \\( fãrã pereche"
+#~ msgid "Unmatched \\{"
+#~ msgstr "\\{ fãrã pereche"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "\\{ fãrã pereche"
+#~ msgid "Invalid range end"
+#~ msgstr "Sfârºit de interval incorect"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Conþinut incorect pentru \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Memorie epuizatã"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Sfârºit de interval incorect"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Expresie regularã precedentã incorectã"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Memorie epuizatã"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Sfârºit prematur al expresiei regulare"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Expresie regularã precedentã incorectã"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr ") sau \\) fãrã pereche"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Sfârºit prematur al expresiei regulare"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Expresie regularã prea mare"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ") sau \\) fãrã pereche"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Nici o expresie regularã anterioarã"
+#~ msgid "No previous regular expression"
+#~ msgstr "Nici o expresie regularã anterioarã"
diff --git a/po/ru.po b/po/ru.po
index 1cb4ef8..a6a7eec 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed-4.1.1\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-07-07 17:54+0300\n"
"Last-Translator: Pavel Maryanov \n"
"Language-Team: Russian \n"
@@ -16,6 +16,206 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n>1;\n"
"X-Generator: KBabel 1.3\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "ÎÅÉÚ×ÅÓÔÎÙÊ ÍÏÄÉÆÉËÁÔÏÒ Ë `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "ÏÛÉÂËÁ ÞÔÅÎÉÑ %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÉÍÑ ÄÌÑ ËÌÁÓÓÁ ÓÉÍ×ÏÌÁ"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "ÎÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "ÎÅÉÚ×ÅÓÔÎÙÊ ÍÏÄÉÆÉËÁÔÏÒ Ë `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "ÏÔÓÕÔÓÔ×ÕÅÔ ËÏÍÁÎÄÁ"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "òÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "ÏÐÃÉÑ `e' ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔÓÑ"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÓÏÄÅÒÖÉÍÏÅ × \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr "ÎÅÓËÏÌØËÏ ÓÉÍ×ÏÌÏ× `!'"
@@ -369,74 +569,47 @@ msgstr "
msgid "cannot rename %s: %s"
msgstr "ÎÅ×ÏÚÍÏÖÎÏ ÐÅÒÅÉÍÅÎÏ×ÁÔØ %s: %s"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "õÓÐÅÛÎÏ"
+#~ msgid "Success"
+#~ msgstr "õÓÐÅÛÎÏ"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "îÅÔ ÓÏÏÔ×ÅÓÔ×ÉÑ"
+#~ msgid "No match"
+#~ msgstr "îÅÔ ÓÏÏÔ×ÅÓÔ×ÉÑ"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ"
+#~ msgid "Invalid regular expression"
+#~ msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "îÅÄÏÐÕÓÔÉÍÙÊ ÓÉÍ×ÏÌ ÓÒÁ×ÎÅÎÉÑ"
+#~ msgid "Invalid collation character"
+#~ msgstr "îÅÄÏÐÕÓÔÉÍÙÊ ÓÉÍ×ÏÌ ÓÒÁ×ÎÅÎÉÑ"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÉÍÑ ÄÌÑ ËÌÁÓÓÁ ÓÉÍ×ÏÌÁ"
+#~ msgid "Trailing backslash"
+#~ msgstr "úÁ×ÅÒÛÁÀÝÁÑ ÏÂÒÁÔÎÁÑ ËÏÓÁÑ ÞÅÒÔÁ"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "úÁ×ÅÒÛÁÀÝÁÑ ÏÂÒÁÔÎÁÑ ËÏÓÁÑ ÞÅÒÔÁ"
+#~ msgid "Invalid back reference"
+#~ msgstr "îÅÄÏÐÕÓÔÉÍÁÑ ÏÂÒÁÔÎÁÑ ÓÓÙÌËÁ"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "îÅÄÏÐÕÓÔÉÍÁÑ ÏÂÒÁÔÎÁÑ ÓÓÙÌËÁ"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "îÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ [ ÉÌÉ [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "îÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ [ ÉÌÉ [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "îÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ ( or \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "îÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ ( or \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "îÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "îÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÏËÏÎÞÁÎÉÅ ÄÉÁÐÁÚÏÎÁ"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÓÏÄÅÒÖÉÍÏÅ × \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "ðÁÍÑÔØ ÉÓÞÅÒÐÁÎÁ"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÏËÏÎÞÁÎÉÅ ÄÉÁÐÁÚÏÎÁ"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÐÒÅÄÛÅÓÔ×ÕÀÝÅÅ ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "ðÁÍÑÔØ ÉÓÞÅÒÐÁÎÁ"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "ðÒÅÖÄÅ×ÒÅÍÅÎÎÏÅ ÏËÏÎÞÁÎÉÅ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "îÅÄÏÐÕÓÔÉÍÏÅ ÐÒÅÄÛÅÓÔ×ÕÀÝÅÅ ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "îÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ ) ÉÌÉ \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "ðÒÅÖÄÅ×ÒÅÍÅÎÎÏÅ ÏËÏÎÞÁÎÉÅ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "òÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "îÅÐÁÒÎÙÊ ÓÉÍ×ÏÌ ) ÉÌÉ \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ"
+#~ msgid "No previous regular expression"
+#~ msgstr "îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ"
diff --git a/po/sk.po b/po/sk.po
index 9d61079..f21a9bd 100644
--- a/po/sk.po
+++ b/po/sk.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: GNU sed 4.0.8\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-10-25 17:22+0200\n"
"Last-Translator: Marcel Telka \n"
"Language-Team: Slovak \n"
@@ -16,6 +16,206 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"Plural-Forms: nplurals=3; plural= (n==1) ? 1 : (n>=2 && n<=4) ? 2 : 0;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Neznáma voľba pre `s'"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "chyba pri Ä�Ãtanà z %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Neplatný názov triedy znakov"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Nezodpovedajúca `{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Neznáma voľba pre `s'"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Chýbajúci prÃkaz"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Regulárny výraz je prÃliÅ¡ veľký"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "voľba `e' nie je podporovaná"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Neplatný obsah \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -362,74 +562,47 @@ msgstr "chyba pri Ä�Ãtanà z %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: %s nie je možné Ä�ÃtaÅ¥: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Úspech"
+#~ msgid "Success"
+#~ msgstr "Úspech"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Nezodpovedá"
+#~ msgid "No match"
+#~ msgstr "Nezodpovedá"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Neplatný regulárny výraz"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Neplatný regulárny výraz"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Neplatný znak pre porovnávanie"
+#~ msgid "Invalid collation character"
+#~ msgstr "Neplatný znak pre porovnávanie"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Neplatný názov triedy znakov"
+#~ msgid "Trailing backslash"
+#~ msgstr "UkonÄ�ovacie opaÄ�né lomÃtko"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "UkonÄ�ovacie opaÄ�né lomÃtko"
+#~ msgid "Invalid back reference"
+#~ msgstr "Neplatný spätný odkaz"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Neplatný spätný odkaz"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Nezodpovedajúca [ alebo [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Nezodpovedajúca [ alebo [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Nezodpovedajúca ( alebo \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Nezodpovedajúca ( alebo \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Nezodpovedajúca \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Nezodpovedajúca \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Neplatný koniec rozsahu"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Neplatný obsah \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Vy�erpaná pamäť"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Neplatný koniec rozsahu"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Neplatný predchádzajúci regulárny výraz"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Vy�erpaná pamäť"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Neo�akávaný koniec regulárneho výrazu"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Neplatný predchádzajúci regulárny výraz"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Nezodpovedajúca ) alebo \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Neo�akávaný koniec regulárneho výrazu"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Regulárny výraz je prÃliÅ¡ veľký"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Nezodpovedajúca ) alebo \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Bez predchádzajúceho regulárneho výrazu"
+#~ msgid "No previous regular expression"
+#~ msgstr "Bez predchádzajúceho regulárneho výrazu"
diff --git a/po/sl.po b/po/sl.po
index eb8d889..6c8dba4 100644
--- a/po/sl.po
+++ b/po/sl.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.6\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2003-04-02 17:20+0200\n"
"Last-Translator: Primo¾ Peterlin \n"
"Language-Team: Slovenian \n"
@@ -17,6 +17,206 @@ msgstr ""
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n"
"%100==4 ? 3 : 0);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "Neznane izbire pri ukazu \"s\""
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "napaka pri branju z %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Neveljavno ime razreda znakov"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "Oklepaj { brez zaklepaja"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "Neznane izbire pri ukazu \"s\""
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Ukaz manjka"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Regularni izraz prevelik"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "Izbira ,e` ni podprta"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Neveljavna vsebina \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -362,74 +562,47 @@ msgstr "napaka pri branju z %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: %s ni mo¾no prebrati: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Uspe¹no"
+#~ msgid "Success"
+#~ msgstr "Uspe¹no"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Ni ujemanja"
+#~ msgid "No match"
+#~ msgstr "Ni ujemanja"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Neveljavni regularni izraz"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Neveljavni regularni izraz"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Znaka izven abecede"
+#~ msgid "Invalid collation character"
+#~ msgstr "Znaka izven abecede"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Neveljavno ime razreda znakov"
+#~ msgid "Trailing backslash"
+#~ msgstr "Zakljuèna obrnjena po¹evnica"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Zakljuèna obrnjena po¹evnica"
+#~ msgid "Invalid back reference"
+#~ msgstr "Neveljavni povratni sklic"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Neveljavni povratni sklic"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Oklepaj [ ali [^ brez zaklepaja"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Oklepaj [ ali [^ brez zaklepaja"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Oklepaj ( ali \\( brez zaklepaja"
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Oklepaj ( ali \\( brez zaklepaja"
+#~ msgid "Unmatched \\{"
+#~ msgstr "Oklepaj \\{ brez zaklepaja"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Oklepaj \\{ brez zaklepaja"
+#~ msgid "Invalid range end"
+#~ msgstr "Neveljavna zgornja meja intervala"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Neveljavna vsebina \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Zmanjkalo pomnilnika"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Neveljavna zgornja meja intervala"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Neveljaven prej¹nji regularni izraz"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Zmanjkalo pomnilnika"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Predèasni zakljuèek regularnega izraza"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Neveljaven prej¹nji regularni izraz"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Oklepaj ) ali \\) brez zaklepaja"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Predèasni zakljuèek regularnega izraza"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Regularni izraz prevelik"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Oklepaj ) ali \\) brez zaklepaja"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Prej¹nji regularni izraz manjka"
+#~ msgid "No previous regular expression"
+#~ msgstr "Prej¹nji regularni izraz manjka"
diff --git a/po/sr.po b/po/sr.po
index 72b7e75..04b260d 100644
--- a/po/sr.po
+++ b/po/sr.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.9\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-01-13 22:51-0500\n"
"Last-Translator: Aleksandar Jelenak \n"
"Language-Team: Serbian \n"
@@ -16,6 +16,206 @@ msgstr ""
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : (n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "�епозната опција за „s“"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "грешка учитавања на %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "�еи�правно име кла�е знакова"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "�е�парена „{“"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "�епозната опција за „s“"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "�едо�таје наредба"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Регуларни израз �увише велик"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "опција „e“ није подржана"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "�еи�правни �адржај у \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -359,74 +559,47 @@ msgstr "грешка учитавања на %s: %s"
msgid "cannot rename %s: %s"
msgstr "%s: не може читати %s: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "У�пех"
+#~ msgid "Success"
+#~ msgstr "У�пех"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Без поклапања"
+#~ msgid "No match"
+#~ msgstr "Без поклапања"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "�еи�правни регуларни израз"
+#~ msgid "Invalid regular expression"
+#~ msgstr "�еи�правни регуларни израз"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "�еи�правни знак прикупљања"
+#~ msgid "Invalid collation character"
+#~ msgstr "�еи�правни знак прикупљања"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "�еи�правно име кла�е знакова"
+#~ msgid "Trailing backslash"
+#~ msgstr "Пратећа обрнута ко�а црта"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Пратећа обрнута ко�а црта"
+#~ msgid "Invalid back reference"
+#~ msgstr "�еи�правна повратна референца"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "�еи�правна повратна референца"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "�е�парено [ или ^["
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "�е�парено [ или ^["
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "�е�парено ( или \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "�е�парено ( или \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "�е�парено \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "�е�парено \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "�еи�правни крај оп�ега"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "�еи�правни �адржај у \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Меморија и�црпљена"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "�еи�правни крај оп�ега"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "�еи�праван претходећи регуларни израз"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Меморија и�црпљена"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Преран крај регуларног израза"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "�еи�праван претходећи регуларни израз"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "�е�парено ) или \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Преран крај регуларног израза"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Регуларни израз �увише велик"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "�е�парено ) или \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Без претходног регуларног израза"
+#~ msgid "No previous regular expression"
+#~ msgstr "Без претходног регуларног израза"
diff --git a/po/sed.pot b/po/ssed.pot
similarity index 67%
rename from po/sed.pot
rename to po/ssed.pot
index 9f1b67e..60cd50c 100644
--- a/po/sed.pot
+++ b/po/ssed.pot
@@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -16,6 +16,199 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr ""
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr ""
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+msgid "invalid escape sequence in character class"
+msgstr ""
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+msgid "unmatched braces"
+msgstr ""
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+msgid "unknown option bit(s) set"
+msgstr ""
+
+#: pcre/regexp.c:65
+msgid "missing ) after comment"
+msgstr ""
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+msgid "regular expression too large"
+msgstr ""
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+msgid "POSIX collating elements are not supported"
+msgstr ""
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+msgid "invalid repeat counts in {}"
+msgstr ""
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr ""
@@ -326,75 +519,3 @@ msgstr ""
#, c-format
msgid "cannot rename %s: %s"
msgstr ""
-
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr ""
-
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr ""
-
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr ""
-
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr ""
-
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr ""
-
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr ""
-
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr ""
-
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr ""
-
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr ""
-
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr ""
-
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr ""
-
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr ""
-
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr ""
-
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr ""
-
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr ""
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr ""
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr ""
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr ""
diff --git a/po/sv.po b/po/sv.po
index 111e676..4552057 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.1.1\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-07-11 11:45+0200\n"
"Last-Translator: Christian Rose \n"
"Language-Team: Swedish \n"
@@ -14,6 +14,206 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "flaggan okänd för \"s\""
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "läsfel vid %s: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Ogiltigt teckenklassnamn"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "obalanserad \"{\""
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "flaggan okänd för \"s\""
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "kommando saknas"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Reguljärt uttryck för stort"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr "flaggan \"e\" stöds inte"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "Ogiltigt innehåll i \\{\\}"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
msgid "multiple `!'s"
msgstr "flera \"!\""
@@ -373,74 +573,47 @@ msgstr "l
msgid "cannot rename %s: %s"
msgstr "kan inte byta namn på %s: %s"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Lyckades"
+#~ msgid "Success"
+#~ msgstr "Lyckades"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Ingen träff"
+#~ msgid "No match"
+#~ msgstr "Ingen träff"
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Ogiltigt reguljärt uttryck"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Ogiltigt reguljärt uttryck"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Ogiltigt sorteringstecken"
+#~ msgid "Invalid collation character"
+#~ msgstr "Ogiltigt sorteringstecken"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Ogiltigt teckenklassnamn"
+#~ msgid "Trailing backslash"
+#~ msgstr "Eftersläpande omvänt snedstreck"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Eftersläpande omvänt snedstreck"
+#~ msgid "Invalid back reference"
+#~ msgstr "Ogiltig bakåtreferens"
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Ogiltig bakåtreferens"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "Obalanserad [ eller [^"
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "Obalanserad [ eller [^"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "Obalanserad ( eller \\("
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "Obalanserad ( eller \\("
+#~ msgid "Unmatched \\{"
+#~ msgstr "Obalanserad \\{"
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "Obalanserad \\{"
+#~ msgid "Invalid range end"
+#~ msgstr "Ogiltigt intervallslut"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "Ogiltigt innehåll i \\{\\}"
+#~ msgid "Memory exhausted"
+#~ msgstr "Minnet slut"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Ogiltigt intervallslut"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Ogiltigt föregående reguljärt uttryck"
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Minnet slut"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "För tidigt slut på reguljärt uttryck"
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Ogiltigt föregående reguljärt uttryck"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "Obalanserad ) eller \\)"
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "För tidigt slut på reguljärt uttryck"
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Reguljärt uttryck för stort"
-
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "Obalanserad ) eller \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Inget tidigare reguljärt uttryck"
+#~ msgid "No previous regular expression"
+#~ msgstr "Inget tidigare reguljärt uttryck"
diff --git a/po/tr.po b/po/tr.po
index a74ed33..d2816a8 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 4.0.9\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2004-05-19 18:06+0300\n"
"Last-Translator: Deniz Akkus Kanca \n"
"Language-Team: Turkish \n"
@@ -15,6 +15,207 @@ msgstr ""
"X-Generator: KBabel 1.0.2\n"
"Plural-Forms: nplurals=1; plural=0;\n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "`s' komutuna bilinmeyen seçenek verilmiş"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "%s'de okuma hatası: %s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+#, fuzzy
+msgid "invalid escape sequence in character class"
+msgstr "Hatalı karakter sınıf ismi"
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "EÅŸleÅŸmeyen '{'"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "`s' komutuna bilinmeyen seçenek verilmiş"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "Komut eksik"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#
+#: pcre/regexp.c:67 pcre/regexp.c:137
+#, fuzzy
+msgid "regular expression too large"
+msgstr "Düzenli ifade fazla büyük"
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+#, fuzzy
+msgid "POSIX collating elements are not supported"
+msgstr " e' seçeneği desteklenmiyor"
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+#, fuzzy
+msgid "invalid repeat counts in {}"
+msgstr "\\{\\} içeriği hatalı"
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -358,82 +559,54 @@ msgstr "%s'de okuma hatası: %s"
msgid "cannot rename %s: %s"
msgstr "%s: %s okunamıyor: %s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr "Başarılı"
+#~ msgid "Success"
+#~ msgstr "Başarılı"
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr "Eşleşme bulunamadı"
+#~ msgid "No match"
+#~ msgstr "Eşleşme bulunamadı"
#
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr "Hatalı düzenli ifade"
+#~ msgid "Invalid regular expression"
+#~ msgstr "Hatalı düzenli ifade"
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr "Hatalı birleştirme karakteri"
+#~ msgid "Invalid collation character"
+#~ msgstr "Hatalı birleştirme karakteri"
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr "Hatalı karakter sınıf ismi"
+#~ msgid "Trailing backslash"
+#~ msgstr "Sonda fazla gerikesme var"
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr "Sonda fazla gerikesme var"
-
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr "Hatalı geri referans"
+#~ msgid "Invalid back reference"
+#~ msgstr "Hatalı geri referans"
#
-#: lib/regcomp.c:171
-msgid "Unmatched [ or [^"
-msgstr "EÅŸleÅŸmeyen [ veya [^"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "EÅŸleÅŸmeyen [ veya [^"
#
-#: lib/regcomp.c:174
-msgid "Unmatched ( or \\("
-msgstr "EÅŸleÅŸmeyen ( veya \\("
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "EÅŸleÅŸmeyen ( veya \\("
#
-#: lib/regcomp.c:177
-msgid "Unmatched \\{"
-msgstr "EÅŸleÅŸmeyen \\{"
+#~ msgid "Unmatched \\{"
+#~ msgstr "EÅŸleÅŸmeyen \\{"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr "\\{\\} içeriği hatalı"
+#~ msgid "Invalid range end"
+#~ msgstr "Geçersiz kapsam sonu"
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr "Geçersiz kapsam sonu"
-
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr "Bellek tükendi"
+#~ msgid "Memory exhausted"
+#~ msgstr "Bellek tükendi"
#
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr "Bir önceki düzenli ifade hatalı"
+#~ msgid "Invalid preceding regular expression"
+#~ msgstr "Bir önceki düzenli ifade hatalı"
#
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr "Düzenli ifade erken sonlandı"
+#~ msgid "Premature end of regular expression"
+#~ msgstr "Düzenli ifade erken sonlandı"
#
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr "Düzenli ifade fazla büyük"
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "EÅŸleÅŸmeyen ) or \\)"
-#
-#: lib/regcomp.c:198
-msgid "Unmatched ) or \\)"
-msgstr "EÅŸleÅŸmeyen ) or \\)"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr "Daha önce düzenli ifade yok"
+#~ msgid "No previous regular expression"
+#~ msgstr "Daha önce düzenli ifade yok"
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 2a5ef9a..243a026 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: sed 3.02.80\n"
-"POT-Creation-Date: 2004-08-21 20:46+0200\n"
+"POT-Creation-Date: 2004-07-13 20:07+0200\n"
"PO-Revision-Date: 2002-08-18 11:11+0800\n"
"Last-Translator: Wang Li \n"
"Language-Team: Chinese (simplified) \n"
@@ -14,6 +14,202 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Report-Msgid-Bugs-To: \n"
+#: pcre/pcregrep.c:130
+msgid "Usage: pcregrep [-bepchilnsvx] pattern [file] ...\n"
+msgstr ""
+
+#: pcre/pcregrep.c:212
+#, fuzzy, c-format
+msgid "pcregrep: unknown option %c\n"
+msgstr "¡°s¡±µÄδ֪ѡÏî"
+
+#: pcre/pcregrep.c:239
+#, c-format
+msgid "pcregrep: error in regex at offset %d: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:248
+#, c-format
+msgid "pcregrep: error while studing regex: %s\n"
+msgstr ""
+
+#: pcre/pcregrep.c:268
+#, fuzzy, c-format
+msgid "pcregrep: failed to open %s: %s\n"
+msgstr "¶ÁÈ¡ %s ³ö´í£º%s"
+
+#: pcre/regexp.c:48
+msgid "\\ at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:49
+msgid "\\c at end of pattern"
+msgstr ""
+
+#: pcre/regexp.c:50
+msgid "unrecognized character follows \\"
+msgstr ""
+
+#: pcre/regexp.c:51
+msgid "numbers out of order in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:52
+msgid "number too big in {} quantifier"
+msgstr ""
+
+#: pcre/regexp.c:53 pcre/regexp.c:130
+msgid "missing terminating ] for character class"
+msgstr ""
+
+#: pcre/regexp.c:54
+msgid "invalid escape sequence in character class"
+msgstr ""
+
+#: pcre/regexp.c:55 pcre/regexp.c:136
+msgid "range out of order in character class"
+msgstr ""
+
+#: pcre/regexp.c:56 pcre/regexp.c:128
+msgid "nothing to repeat"
+msgstr ""
+
+#: pcre/regexp.c:57
+msgid "operand of unlimited repeat could match the empty string"
+msgstr ""
+
+#: pcre/regexp.c:58
+msgid "internal error: unexpected repeat"
+msgstr ""
+
+#: pcre/regexp.c:59
+msgid "unrecognized character after (?"
+msgstr ""
+
+#: pcre/regexp.c:60
+msgid "unused error"
+msgstr ""
+
+#: pcre/regexp.c:61 pcre/regexp.c:129
+#, fuzzy
+msgid "unmatched braces"
+msgstr "δƥÅäµÄ¡°{¡±"
+
+#: pcre/regexp.c:62 pcre/regexp.c:139
+msgid "back reference to non-existent subpattern"
+msgstr ""
+
+#: pcre/regexp.c:63
+msgid "erroffset passed as NULL"
+msgstr ""
+
+#: pcre/regexp.c:64
+#, fuzzy
+msgid "unknown option bit(s) set"
+msgstr "¡°s¡±µÄδ֪ѡÏî"
+
+#: pcre/regexp.c:65
+#, fuzzy
+msgid "missing ) after comment"
+msgstr "ÒÅ©ÃüÁî"
+
+#: pcre/regexp.c:66
+msgid "parentheses nested too deeply"
+msgstr ""
+
+#: pcre/regexp.c:67 pcre/regexp.c:137
+msgid "regular expression too large"
+msgstr ""
+
+#: pcre/regexp.c:68 pcre/regexp.c:138
+msgid "failed to get memory"
+msgstr ""
+
+#: pcre/regexp.c:69 pcre/regexp.c:135
+msgid "unmatched parentheses"
+msgstr ""
+
+#: pcre/regexp.c:70
+msgid "internal error: code overflow"
+msgstr ""
+
+#: pcre/regexp.c:71
+msgid "unrecognized character after (?<"
+msgstr ""
+
+#: pcre/regexp.c:72
+msgid "lookbehind assertion is not fixed length"
+msgstr ""
+
+#: pcre/regexp.c:73
+msgid "malformed number after (?("
+msgstr ""
+
+#: pcre/regexp.c:74
+msgid "conditional group contains more than two branches"
+msgstr ""
+
+#: pcre/regexp.c:75
+msgid "assertion expected after (?("
+msgstr ""
+
+#: pcre/regexp.c:76
+msgid "(?p must be followed by )"
+msgstr ""
+
+#: pcre/regexp.c:77 pcre/regexp.c:132
+msgid "unknown POSIX class name"
+msgstr ""
+
+#: pcre/regexp.c:78
+msgid "POSIX collating elements are not supported"
+msgstr ""
+
+#: pcre/regexp.c:79
+msgid "bad condition (?(0)"
+msgstr ""
+
+#: pcre/regexp.c:125
+msgid "internal error"
+msgstr ""
+
+#: pcre/regexp.c:126
+msgid "invalid repeat counts in {}"
+msgstr ""
+
+#: pcre/regexp.c:127
+msgid "pattern error"
+msgstr ""
+
+#: pcre/regexp.c:131
+msgid "bad collating element"
+msgstr ""
+
+#: pcre/regexp.c:133
+msgid "bad escape sequence"
+msgstr ""
+
+#: pcre/regexp.c:134
+msgid "empty expression"
+msgstr ""
+
+#: pcre/regexp.c:140
+msgid "bad argument"
+msgstr ""
+
+#: pcre/regexp.c:141
+msgid "match failed"
+msgstr ""
+
+#: pcre/regexp.c:182
+msgid "unknown error code"
+msgstr ""
+
+#: pcre/regexp.c:184
+#, c-format
+msgid "%s at offset %-6d"
+msgstr ""
+
#: sed/compile.c:162
#, fuzzy
msgid "multiple `!'s"
@@ -342,78 +538,18 @@ msgstr "
msgid "cannot rename %s: %s"
msgstr "%s£ºÎÞ·¨¶ÁÈ¡ %s£º%s\n"
-#: lib/regcomp.c:150
-msgid "Success"
-msgstr ""
-
-#: lib/regcomp.c:153
-msgid "No match"
-msgstr ""
-
-#: lib/regcomp.c:156
-msgid "Invalid regular expression"
-msgstr ""
-
-#: lib/regcomp.c:159
-msgid "Invalid collation character"
-msgstr ""
-
-#: lib/regcomp.c:162
-msgid "Invalid character class name"
-msgstr ""
-
-#: lib/regcomp.c:165
-msgid "Trailing backslash"
-msgstr ""
-
-#: lib/regcomp.c:168
-msgid "Invalid back reference"
-msgstr ""
-
-#: lib/regcomp.c:171
#, fuzzy
-msgid "Unmatched [ or [^"
-msgstr "δƥÅäµÄ¡°{¡±"
+#~ msgid "Unmatched [ or [^"
+#~ msgstr "δƥÅäµÄ¡°{¡±"
-#: lib/regcomp.c:174
#, fuzzy
-msgid "Unmatched ( or \\("
-msgstr "δƥÅäµÄ¡°{¡±"
+#~ msgid "Unmatched ( or \\("
+#~ msgstr "δƥÅäµÄ¡°{¡±"
-#: lib/regcomp.c:177
#, fuzzy
-msgid "Unmatched \\{"
-msgstr "δƥÅäµÄ¡°{¡±"
+#~ msgid "Unmatched \\{"
+#~ msgstr "δƥÅäµÄ¡°{¡±"
-#: lib/regcomp.c:180
-msgid "Invalid content of \\{\\}"
-msgstr ""
-
-#: lib/regcomp.c:183
-msgid "Invalid range end"
-msgstr ""
-
-#: lib/regcomp.c:186
-msgid "Memory exhausted"
-msgstr ""
-
-#: lib/regcomp.c:189
-msgid "Invalid preceding regular expression"
-msgstr ""
-
-#: lib/regcomp.c:192
-msgid "Premature end of regular expression"
-msgstr ""
-
-#: lib/regcomp.c:195
-msgid "Regular expression too big"
-msgstr ""
-
-#: lib/regcomp.c:198
#, fuzzy
-msgid "Unmatched ) or \\)"
-msgstr "δƥÅäµÄ¡°{¡±"
-
-#: lib/regcomp.c:672
-msgid "No previous regular expression"
-msgstr ""
+#~ msgid "Unmatched ) or \\)"
+#~ msgstr "δƥÅäµÄ¡°{¡±"
diff --git a/sed/Makefile.am b/sed/Makefile.am
index ec40c20..8997d15 100644
--- a/sed/Makefile.am
+++ b/sed/Makefile.am
@@ -6,12 +6,12 @@ localedir = $(datadir)/locale
sed_SOURCES = sed.c compile.c execute.c regexp.c fmt.c mbcs.c
noinst_HEADERS = sed.h
-AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/intl \
+AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/intl -I$(top_srcdir)/pcre \
-I$(top_srcdir) -I$(top_builddir)/lib \
-DLOCALEDIR=\"$(localedir)\"
-sed_LDADD = ../lib/libsed.a @INTLLIBS@
-sed_DEPENDENCIES = ../lib/libsed.a
+sed_LDADD = ../pcre/libpcre.a ../lib/libsed.a @INTLLIBS@
+sed_DEPENDENCIES = ../pcre/libpcre.a ../lib/libsed.a
$(PROGRAMS): $(LDADD)
diff --git a/sed/sed.h b/sed/sed.h
index 01969d9..d53f370 100644
--- a/sed/sed.h
+++ b/sed/sed.h
@@ -21,7 +21,7 @@
#endif
#include "basicdefs.h"
-#include "regex.h"
+#include "regexp.h"
#ifndef BOOTSTRAP
#include
@@ -250,5 +250,4 @@ extern int mb_cur_max;
#endif
extern int brlen P_ ((int ch, mbstate_t *ps));
-extern void initialize_mbcs P_ ((void));
diff --git a/testsuite/BOOST.tests b/testsuite/BOOST.tests
deleted file mode 100644
index 98fd3b6..0000000
--- a/testsuite/BOOST.tests
+++ /dev/null
@@ -1,829 +0,0 @@
-;
-;
-; this file contains a script of tests to run through regress.exe
-;
-; comments start with a semicolon and proceed to the end of the line
-;
-; changes to regular expression compile flags start with a "-" as the first
-; non-whitespace character and consist of a list of the printable names
-; of the flags, for example "match_default"
-;
-; Other lines contain a test to perform using the current flag status
-; the first token contains the expression to compile, the second the string
-; to match it against. If the second string is "!" then the expression should
-; not compile, that is the first string is an invalid regular expression.
-; This is then followed by a list of integers that specify what should match,
-; each pair represents the starting and ending positions of a subexpression
-; starting with the zeroth subexpression (the whole match).
-; A value of -1 indicates that the subexpression should not take part in the
-; match at all, if the first value is -1 then no part of the expression should
-; match the string.
-;
-; Tests taken from BOOST testsuite and adapted to glibc regex.
-;
-; Boost Software License - Version 1.0 - August 17th, 2003
-;
-; Permission is hereby granted, free of charge, to any person or organization
-; obtaining a copy of the software and accompanying documentation covered by
-; this license (the "Software") to use, reproduce, display, distribute,
-; execute, and transmit the Software, and to prepare derivative works of the
-; Software, and to permit third-parties to whom the Software is furnished to
-; do so, all subject to the following:
-;
-; The copyright notices in the Software and this entire statement, including
-; the above license grant, this restriction and the following disclaimer,
-; must be included in all copies of the Software, in whole or in part, and
-; all derivative works of the Software, unless such copies or derivative
-; works are solely in the form of machine-executable object code generated by
-; a source language processor.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-; SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-; FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-; ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-; DEALINGS IN THE SOFTWARE.
-;
-
-- match_default normal REG_EXTENDED
-
-;
-; try some really simple literals:
-a a 0 1
-Z Z 0 1
-Z aaa -1 -1
-Z xxxxZZxxx 4 5
-
-; and some simple brackets:
-(a) zzzaazz 3 4 3 4
-() zzz 0 0 0 0
-() "" 0 0 0 0
-( !
-) ) 0 1
-(aa !
-aa) baa)b 1 4
-a b -1 -1
-\(\) () 0 2
-\(a\) (a) 0 3
-\() () 0 2
-(\) !
-p(a)rameter ABCparameterXYZ 3 12 4 5
-[pq](a)rameter ABCparameterXYZ 3 12 4 5
-
-; now try escaped brackets:
-- match_default bk_parens REG_BASIC
-\(a\) zzzaazz 3 4 3 4
-\(\) zzz 0 0 0 0
-\(\) "" 0 0 0 0
-\( !
-\) !
-\(aa !
-aa\) !
-() () 0 2
-(a) (a) 0 3
-(\) !
-\() !
-
-; now move on to "." wildcards
-- match_default normal REG_EXTENDED REG_STARTEND
-. a 0 1
-. \n 0 1
-. \r 0 1
-. \0 0 1
-
-;
-; now move on to the repetion ops,
-; starting with operator *
-- match_default normal REG_EXTENDED
-a* b 0 0
-ab* a 0 1
-ab* ab 0 2
-ab* sssabbbbbbsss 3 10
-ab*c* a 0 1
-ab*c* abbb 0 4
-ab*c* accc 0 4
-ab*c* abbcc 0 5
-*a !
-\<* !
-\>* !
-\n* \n\n 0 2
-\** ** 0 2
-\* * 0 1
-
-; now try operator +
-ab+ a -1 -1
-ab+ ab 0 2
-ab+ sssabbbbbbsss 3 10
-ab+c+ a -1 -1
-ab+c+ abbb -1 -1
-ab+c+ accc -1 -1
-ab+c+ abbcc 0 5
-+a !
-\<+ !
-\>+ !
-\n+ \n\n 0 2
-\+ + 0 1
-\+ ++ 0 1
-\++ ++ 0 2
-
-; now try operator ?
-- match_default normal REG_EXTENDED
-a? b 0 0
-ab? a 0 1
-ab? ab 0 2
-ab? sssabbbbbbsss 3 5
-ab?c? a 0 1
-ab?c? abbb 0 2
-ab?c? accc 0 2
-ab?c? abcc 0 3
-?a !
-\ !
-\>? !
-\n? \n\n 0 1
-\? ? 0 1
-\? ?? 0 1
-\?? ?? 0 1
-
-; now try operator {}
-- match_default normal REG_EXTENDED
-a{2} a -1 -1
-a{2} aa 0 2
-a{2} aaa 0 2
-a{2,} a -1 -1
-a{2,} aa 0 2
-a{2,} aaaaa 0 5
-a{2,4} a -1 -1
-a{2,4} aa 0 2
-a{2,4} aaa 0 3
-a{2,4} aaaa 0 4
-a{2,4} aaaaa 0 4
-a{} !
-a{2 !
-a} a} 0 2
-\{\} {} 0 2
-
-- match_default normal REG_BASIC
-a\{2\} a -1 -1
-a\{2\} aa 0 2
-a\{2\} aaa 0 2
-a\{2,\} a -1 -1
-a\{2,\} aa 0 2
-a\{2,\} aaaaa 0 5
-a\{2,4\} a -1 -1
-a\{2,4\} aa 0 2
-a\{2,4\} aaa 0 3
-a\{2,4\} aaaa 0 4
-a\{2,4\} aaaaa 0 4
-{} {} 0 2
-
-; now test the alternation operator |
-- match_default normal REG_EXTENDED
-a|b a 0 1
-a|b b 0 1
-a(b|c) ab 0 2 1 2
-a(b|c) ac 0 2 1 2
-a(b|c) ad -1 -1 -1 -1
-a\| a| 0 2
-
-; now test the set operator []
-- match_default normal REG_EXTENDED
-; try some literals first
-[abc] a 0 1
-[abc] b 0 1
-[abc] c 0 1
-[abc] d -1 -1
-[^bcd] a 0 1
-[^bcd] b -1 -1
-[^bcd] d -1 -1
-[^bcd] e 0 1
-a[b]c abc 0 3
-a[ab]c abc 0 3
-a[^ab]c adc 0 3
-a[]b]c a]c 0 3
-a[[b]c a[c 0 3
-a[-b]c a-c 0 3
-a[^]b]c adc 0 3
-a[^-b]c adc 0 3
-a[b-]c a-c 0 3
-a[b !
-a[] !
-
-; then some ranges
-[b-e] a -1 -1
-[b-e] b 0 1
-[b-e] e 0 1
-[b-e] f -1 -1
-[^b-e] a 0 1
-[^b-e] b -1 -1
-[^b-e] e -1 -1
-[^b-e] f 0 1
-a[1-3]c a2c 0 3
-a[3-1]c !
-a[1-3-5]c !
-a[1- !
-
-; and some classes
-a[[:alpha:]]c abc 0 3
-a[[:unknown:]]c !
-a[[: !
-a[[:alpha !
-a[[:alpha:] !
-a[[:alpha,:] !
-a[[:]:]]b !
-a[[:-:]]b !
-a[[:alph:]] !
-a[[:alphabet:]] !
-[[:alnum:]]+ -%@a0X_- 3 6
-[[:alpha:]]+ -%@aX_0- 3 5
-[[:blank:]]+ "a \tb" 1 4
-[[:cntrl:]]+ a\n\tb 1 3
-[[:digit:]]+ a019b 1 4
-[[:graph:]]+ " a%b " 1 4
-[[:lower:]]+ AabC 1 3
-; This test fails with STLPort, disable for now as this is a corner case anyway...
-;[[:print:]]+ "\na b\n" 1 4
-[[:punct:]]+ " %-&\t" 1 4
-[[:space:]]+ "a \n\t\rb" 1 5
-[[:upper:]]+ aBCd 1 3
-[[:xdigit:]]+ p0f3Cx 1 5
-
-; now test flag settings:
-- escape_in_lists REG_NO_POSIX_TEST
-[\n] \n 0 1
-- REG_NO_POSIX_TEST
-
-; line anchors
-- match_default normal REG_EXTENDED
-^ab ab 0 2
-^ab xxabxx -1 -1
-ab$ ab 0 2
-ab$ abxx -1 -1
-- match_default match_not_bol match_not_eol normal REG_EXTENDED REG_NOTBOL REG_NOTEOL
-^ab ab -1 -1
-^ab xxabxx -1 -1
-ab$ ab -1 -1
-ab$ abxx -1 -1
-
-; back references
-- match_default normal REG_PERL
-a(b)\2c !
-a(b\1)c !
-a(b*)c\1d abbcbbd 0 7 1 3
-a(b*)c\1d abbcbd -1 -1
-a(b*)c\1d abbcbbbd -1 -1
-^(.)\1 abc -1 -1
-a([bc])\1d abcdabbd 4 8 5 6
-; strictly speaking this is at best ambiguous, at worst wrong, this is what most
-; re implimentations will match though.
-a(([bc])\2)*d abbccd 0 6 3 5 3 4
-
-a(([bc])\2)*d abbcbd -1 -1
-a((b)*\2)*d abbbd 0 5 1 4 2 3
-; perl only:
-(ab*)[ab]*\1 ababaaa 0 7 0 1
-(a)\1bcd aabcd 0 5 0 1
-(a)\1bc*d aabcd 0 5 0 1
-(a)\1bc*d aabd 0 4 0 1
-(a)\1bc*d aabcccd 0 7 0 1
-(a)\1bc*[ce]d aabcccd 0 7 0 1
-^(a)\1b(c)*cd$ aabcccd 0 7 0 1 4 5
-
-; posix only:
-- match_default extended REG_EXTENDED
-(ab*)[ab]*\1 ababaaa 0 7 0 1
-
-;
-; word operators:
-\w a 0 1
-\w z 0 1
-\w A 0 1
-\w Z 0 1
-\w _ 0 1
-\w } -1 -1
-\w ` -1 -1
-\w [ -1 -1
-\w @ -1 -1
-; non-word:
-\W a -1 -1
-\W z -1 -1
-\W A -1 -1
-\W Z -1 -1
-\W _ -1 -1
-\W } 0 1
-\W ` 0 1
-\W [ 0 1
-\W @ 0 1
-; word start:
-\ abc 0 3
-abc\> abcd -1 -1
-abc\> abc\n 0 3
-abc\> abc:: 0 3
-; word boundary:
-\babcd " abcd" 2 6
-\bab cab -1 -1
-\bab "\nab" 1 3
-\btag ::tag 2 5
-abc\b abc 0 3
-abc\b abcd -1 -1
-abc\b abc\n 0 3
-abc\b abc:: 0 3
-; within word:
-\B ab 1 1
-a\Bb ab 0 2
-a\B ab 0 1
-a\B a -1 -1
-a\B "a " -1 -1
-
-;
-; buffer operators:
-\`abc abc 0 3
-\`abc \nabc -1 -1
-\`abc " abc" -1 -1
-abc\' abc 0 3
-abc\' abc\n -1 -1
-abc\' "abc " -1 -1
-
-;
-; now follows various complex expressions designed to try and bust the matcher:
-a(((b)))c abc 0 3 1 2 1 2 1 2
-a(b|(c))d abd 0 3 1 2 -1 -1
-a(b|(c))d acd 0 3 1 2 1 2
-a(b*|c)d abbd 0 4 1 3
-; just gotta have one DFA-buster, of course
-a[ab]{20} aaaaabaaaabaaaabaaaab 0 21
-; and an inline expansion in case somebody gets tricky
-a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] aaaaabaaaabaaaabaaaab 0 21
-; and in case somebody just slips in an NFA...
-a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) aaaaabaaaabaaaabaaaabweeknights 0 31 21 24 24 31
-; one really big one
-1234567890123456789012345678901234567890123456789012345678901234567890 a1234567890123456789012345678901234567890123456789012345678901234567890b 1 71
-; fish for problems as brackets go past 8
-[ab][cd][ef][gh][ij][kl][mn] xacegikmoq 1 8
-[ab][cd][ef][gh][ij][kl][mn][op] xacegikmoq 1 9
-[ab][cd][ef][gh][ij][kl][mn][op][qr] xacegikmoqy 1 10
-[ab][cd][ef][gh][ij][kl][mn][op][q] xacegikmoqy 1 10
-; and as parenthesis go past 9:
-(a)(b)(c)(d)(e)(f)(g)(h) zabcdefghi 1 9 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9
-(a)(b)(c)(d)(e)(f)(g)(h)(i) zabcdefghij 1 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
-(a)(b)(c)(d)(e)(f)(g)(h)(i)(j) zabcdefghijk 1 11 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11
-(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k) zabcdefghijkl 1 12 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12
-(a)d|(b)c abc 1 3 -1 -1 1 2
-_+((www)|(ftp)|(mailto)):_* "_wwwnocolon _mailto:" 12 20 13 19 -1 -1 -1 -1 13 19
-
-; subtleties of matching
-;a(b)?c\1d acd 0 3 -1 -1
-; POSIX is about the following test:
-a(b)?c\1d acd -1 -1 -1 -1
-a(b?c)+d accd 0 4 2 3
-(wee|week)(knights|night) weeknights 0 10 0 3 3 10
-.* abc 0 3
-a(b|(c))d abd 0 3 1 2 -1 -1
-a(b|(c))d acd 0 3 1 2 1 2
-a(b*|c|e)d abbd 0 4 1 3
-a(b*|c|e)d acd 0 3 1 2
-a(b*|c|e)d ad 0 2 1 1
-a(b?)c abc 0 3 1 2
-a(b?)c ac 0 2 1 1
-a(b+)c abc 0 3 1 2
-a(b+)c abbbc 0 5 1 4
-a(b*)c ac 0 2 1 1
-(a|ab)(bc([de]+)f|cde) abcdef 0 6 0 1 1 6 3 5
-a([bc]?)c abc 0 3 1 2
-a([bc]?)c ac 0 2 1 1
-a([bc]+)c abc 0 3 1 2
-a([bc]+)c abcc 0 4 1 3
-a([bc]+)bc abcbc 0 5 1 3
-a(bb+|b)b abb 0 3 1 2
-a(bbb+|bb+|b)b abb 0 3 1 2
-a(bbb+|bb+|b)b abbb 0 4 1 3
-a(bbb+|bb+|b)bb abbb 0 4 1 2
-(.*).* abcdef 0 6 0 6
-(a*)* bc 0 0 0 0
-xyx*xz xyxxxxyxxxz 5 11
-
-; do we get the right subexpression when it is used more than once?
-a(b|c)*d ad 0 2 -1 -1
-a(b|c)*d abcd 0 4 2 3
-a(b|c)+d abd 0 3 1 2
-a(b|c)+d abcd 0 4 2 3
-a(b|c?)+d ad 0 2 1 1
-a(b|c){0,0}d ad 0 2 -1 -1
-a(b|c){0,1}d ad 0 2 -1 -1
-a(b|c){0,1}d abd 0 3 1 2
-a(b|c){0,2}d ad 0 2 -1 -1
-a(b|c){0,2}d abcd 0 4 2 3
-a(b|c){0,}d ad 0 2 -1 -1
-a(b|c){0,}d abcd 0 4 2 3
-a(b|c){1,1}d abd 0 3 1 2
-a(b|c){1,2}d abd 0 3 1 2
-a(b|c){1,2}d abcd 0 4 2 3
-a(b|c){1,}d abd 0 3 1 2
-a(b|c){1,}d abcd 0 4 2 3
-a(b|c){2,2}d acbd 0 4 2 3
-a(b|c){2,2}d abcd 0 4 2 3
-a(b|c){2,4}d abcd 0 4 2 3
-a(b|c){2,4}d abcbd 0 5 3 4
-a(b|c){2,4}d abcbcd 0 6 4 5
-a(b|c){2,}d abcd 0 4 2 3
-a(b|c){2,}d abcbd 0 5 3 4
-; perl only: these conflict with the POSIX test below
-;a(b|c?)+d abcd 0 4 3 3
-;a(b+|((c)*))+d abd 0 3 2 2 2 2 -1 -1
-;a(b+|((c)*))+d abcd 0 4 3 3 3 3 2 3
-
-; posix only:
-- match_default extended REG_EXTENDED REG_STARTEND
-
-a(b|c?)+d abcd 0 4 2 3
-a(b|((c)*))+d abcd 0 4 2 3 2 3 2 3
-a(b+|((c)*))+d abd 0 3 1 2 -1 -1 -1 -1
-a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
-a(b|((c)*))+d ad 0 2 1 1 1 1 -1 -1
-a(b|((c)*))*d abcd 0 4 2 3 2 3 2 3
-a(b+|((c)*))*d abd 0 3 1 2 -1 -1 -1 -1
-a(b+|((c)*))*d abcd 0 4 2 3 2 3 2 3
-a(b|((c)*))*d ad 0 2 1 1 1 1 -1 -1
-
-- match_default normal REG_PERL
-; try to match C++ syntax elements:
-; line comment:
-//[^\n]* "++i //here is a line comment\n" 4 28
-; block comment:
-/\*([^*]|\*+[^*/])*\*+/ "/* here is a block comment */" 0 29 26 27
-/\*([^*]|\*+[^*/])*\*+/ "/**/" 0 4 -1 -1
-/\*([^*]|\*+[^*/])*\*+/ "/***/" 0 5 -1 -1
-/\*([^*]|\*+[^*/])*\*+/ "/****/" 0 6 -1 -1
-/\*([^*]|\*+[^*/])*\*+/ "/*****/" 0 7 -1 -1
-/\*([^*]|\*+[^*/])*\*+/ "/*****/*/" 0 7 -1 -1
-; preprossor directives:
-^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol" 0 19 -1 -1
-^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) #x" 0 25 -1 -1
-; perl only:
-^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);" 0 53 30 42
-; literals:
-((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFF 0 4 0 4 0 4 -1 -1 -1 -1 -1 -1 -1 -1
-((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 35 0 2 0 2 -1 -1 0 2 -1 -1 -1 -1 -1 -1
-((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFu 0 5 0 4 0 4 -1 -1 -1 -1 -1 -1 -1 -1
-((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFL 0 5 0 4 0 4 -1 -1 4 5 -1 -1 -1 -1
-((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFFFFFFFFFFFFFFFuint64 0 24 0 18 0 18 -1 -1 19 24 19 24 22 24
-; strings:
-'([^\\']|\\.)*' '\\x3A' 0 6 4 5
-'([^\\']|\\.)*' '\\'' 0 4 1 3
-'([^\\']|\\.)*' '\\n' 0 4 1 3
-
-; finally try some case insensitive matches:
-- match_default normal REG_EXTENDED REG_ICASE
-; upper and lower have no meaning here so they fail, however these
-; may compile with other libraries...
-;[[:lower:]] !
-;[[:upper:]] !
-0123456789@abcdefghijklmnopqrstuvwxyz\[\\\]\^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ\{\|\} 0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]\^_`abcdefghijklmnopqrstuvwxyz\{\|\} 0 72
-
-; known and suspected bugs:
-- match_default normal REG_EXTENDED
-\( ( 0 1
-\) ) 0 1
-\$ $ 0 1
-\^ ^ 0 1
-\. . 0 1
-\* * 0 1
-\+ + 0 1
-\? ? 0 1
-\[ [ 0 1
-\] ] 0 1
-\| | 0 1
-\\ \\ 0 1
-# # 0 1
-\# # 0 1
-a- a- 0 2
-\- - 0 1
-\{ { 0 1
-\} } 0 1
-0 0 0 1
-1 1 0 1
-9 9 0 1
-b b 0 1
-B B 0 1
-< < 0 1
-> > 0 1
-w w 0 1
-W W 0 1
-` ` 0 1
-' ' 0 1
-\n \n 0 1
-, , 0 1
-a a 0 1
-f f 0 1
-n n 0 1
-r r 0 1
-t t 0 1
-v v 0 1
-c c 0 1
-x x 0 1
-: : 0 1
-(\.[[:alnum:]]+){2} "w.a.b " 1 5 3 5
-
-- match_default normal REG_EXTENDED REG_ICASE
-a A 0 1
-A a 0 1
-[abc]+ abcABC 0 6
-[ABC]+ abcABC 0 6
-[a-z]+ abcABC 0 6
-[A-Z]+ abzANZ 0 6
-[a-Z]+ abzABZ 0 6
-[A-z]+ abzABZ 0 6
-[[:lower:]]+ abyzABYZ 0 8
-[[:upper:]]+ abzABZ 0 6
-[[:alpha:]]+ abyzABYZ 0 8
-[[:alnum:]]+ 09abyzABYZ 0 10
-
-; word start:
-\ abc 0 3
-abc\> abcd -1 -1
-abc\> abc\n 0 3
-abc\> abc:: 0 3
-
-; collating elements and rewritten set code:
-- match_default normal REG_EXTENDED REG_STARTEND
-;[[.zero.]] 0 0 1
-;[[.one.]] 1 0 1
-;[[.two.]] 2 0 1
-;[[.three.]] 3 0 1
-[[.a.]] baa 1 2
-;[[.right-curly-bracket.]] } 0 1
-;[[.NUL.]] \0 0 1
-[[:<:]z] !
-[a[:>:]] !
-[[=a=]] a 0 1
-;[[=right-curly-bracket=]] } 0 1
-- match_default normal REG_EXTENDED REG_STARTEND REG_ICASE
-[[.A.]] A 0 1
-[[.A.]] a 0 1
-[[.A.]-b]+ AaBb 0 4
-[A-[.b.]]+ AaBb 0 4
-[[.a.]-B]+ AaBb 0 4
-[a-[.B.]]+ AaBb 0 4
-- match_default normal REG_EXTENDED REG_STARTEND
-[[.a.]-c]+ abcd 0 3
-[a-[.c.]]+ abcd 0 3
-[[:alpha:]-a] !
-[a-[:alpha:]] !
-
-; try mutli-character ligatures:
-;[[.ae.]] ae 0 2
-;[[.ae.]] aE -1 -1
-;[[.AE.]] AE 0 2
-;[[.Ae.]] Ae 0 2
-;[[.ae.]-b] a -1 -1
-;[[.ae.]-b] b 0 1
-;[[.ae.]-b] ae 0 2
-;[a-[.ae.]] a 0 1
-;[a-[.ae.]] b -1 -1
-;[a-[.ae.]] ae 0 2
-- match_default normal REG_EXTENDED REG_STARTEND REG_ICASE
-;[[.ae.]] AE 0 2
-;[[.ae.]] Ae 0 2
-;[[.AE.]] Ae 0 2
-;[[.Ae.]] aE 0 2
-;[[.AE.]-B] a -1 -1
-;[[.Ae.]-b] b 0 1
-;[[.Ae.]-b] B 0 1
-;[[.ae.]-b] AE 0 2
-
-- match_default normal REG_EXTENDED REG_STARTEND REG_NO_POSIX_TEST
-\s+ "ab ab" 2 5
-\S+ " abc " 2 5
-
-- match_default normal REG_EXTENDED REG_STARTEND
-\`abc abc 0 3
-\`abc aabc -1 -1
-abc\' abc 0 3
-abc\' abcd -1 -1
-abc\' abc\n\n -1 -1
-abc\' abc 0 3
-
-; extended repeat checking to exercise new algorithms:
-ab.*xy abxy_ 0 4
-ab.*xy ab_xy_ 0 5
-ab.*xy abxy 0 4
-ab.*xy ab_xy 0 5
-ab.* ab 0 2
-ab.* ab__ 0 4
-
-ab.{2,5}xy ab__xy_ 0 6
-ab.{2,5}xy ab____xy_ 0 8
-ab.{2,5}xy ab_____xy_ 0 9
-ab.{2,5}xy ab__xy 0 6
-ab.{2,5}xy ab_____xy 0 9
-ab.{2,5} ab__ 0 4
-ab.{2,5} ab_______ 0 7
-ab.{2,5}xy ab______xy -1 -1
-ab.{2,5}xy ab_xy -1 -1
-
-ab.*?xy abxy_ 0 4
-ab.*?xy ab_xy_ 0 5
-ab.*?xy abxy 0 4
-ab.*?xy ab_xy 0 5
-ab.*? ab 0 2
-ab.*? ab__ 0 4
-
-ab.{2,5}?xy ab__xy_ 0 6
-ab.{2,5}?xy ab____xy_ 0 8
-ab.{2,5}?xy ab_____xy_ 0 9
-ab.{2,5}?xy ab__xy 0 6
-ab.{2,5}?xy ab_____xy 0 9
-ab.{2,5}? ab__ 0 4
-ab.{2,5}? ab_______ 0 7
-ab.{2,5}?xy ab______xy -1 -1
-ab.{2,5}xy ab_xy -1 -1
-
-; again but with slower algorithm variant:
-- match_default REG_EXTENDED
-; now again for single character repeats:
-
-ab_*xy abxy_ 0 4
-ab_*xy ab_xy_ 0 5
-ab_*xy abxy 0 4
-ab_*xy ab_xy 0 5
-ab_* ab 0 2
-ab_* ab__ 0 4
-
-ab_{2,5}xy ab__xy_ 0 6
-ab_{2,5}xy ab____xy_ 0 8
-ab_{2,5}xy ab_____xy_ 0 9
-ab_{2,5}xy ab__xy 0 6
-ab_{2,5}xy ab_____xy 0 9
-ab_{2,5} ab__ 0 4
-ab_{2,5} ab_______ 0 7
-ab_{2,5}xy ab______xy -1 -1
-ab_{2,5}xy ab_xy -1 -1
-
-ab_*?xy abxy_ 0 4
-ab_*?xy ab_xy_ 0 5
-ab_*?xy abxy 0 4
-ab_*?xy ab_xy 0 5
-ab_*? ab 0 2
-ab_*? ab__ 0 4
-
-ab_{2,5}?xy ab__xy_ 0 6
-ab_{2,5}?xy ab____xy_ 0 8
-ab_{2,5}?xy ab_____xy_ 0 9
-ab_{2,5}?xy ab__xy 0 6
-ab_{2,5}?xy ab_____xy 0 9
-ab_{2,5}? ab__ 0 4
-ab_{2,5}? ab_______ 0 7
-ab_{2,5}?xy ab______xy -1 -1
-ab_{2,5}xy ab_xy -1 -1
-
-; and again for sets:
-ab[_,;]*xy abxy_ 0 4
-ab[_,;]*xy ab_xy_ 0 5
-ab[_,;]*xy abxy 0 4
-ab[_,;]*xy ab_xy 0 5
-ab[_,;]* ab 0 2
-ab[_,;]* ab__ 0 4
-
-ab[_,;]{2,5}xy ab__xy_ 0 6
-ab[_,;]{2,5}xy ab____xy_ 0 8
-ab[_,;]{2,5}xy ab_____xy_ 0 9
-ab[_,;]{2,5}xy ab__xy 0 6
-ab[_,;]{2,5}xy ab_____xy 0 9
-ab[_,;]{2,5} ab__ 0 4
-ab[_,;]{2,5} ab_______ 0 7
-ab[_,;]{2,5}xy ab______xy -1 -1
-ab[_,;]{2,5}xy ab_xy -1 -1
-
-ab[_,;]*?xy abxy_ 0 4
-ab[_,;]*?xy ab_xy_ 0 5
-ab[_,;]*?xy abxy 0 4
-ab[_,;]*?xy ab_xy 0 5
-ab[_,;]*? ab 0 2
-ab[_,;]*? ab__ 0 4
-
-ab[_,;]{2,5}?xy ab__xy_ 0 6
-ab[_,;]{2,5}?xy ab____xy_ 0 8
-ab[_,;]{2,5}?xy ab_____xy_ 0 9
-ab[_,;]{2,5}?xy ab__xy 0 6
-ab[_,;]{2,5}?xy ab_____xy 0 9
-ab[_,;]{2,5}? ab__ 0 4
-ab[_,;]{2,5}? ab_______ 0 7
-ab[_,;]{2,5}?xy ab______xy -1 -1
-ab[_,;]{2,5}xy ab_xy -1 -1
-
-; and again for tricky sets with digraphs:
-;ab[_[.ae.]]*xy abxy_ 0 4
-;ab[_[.ae.]]*xy ab_xy_ 0 5
-;ab[_[.ae.]]*xy abxy 0 4
-;ab[_[.ae.]]*xy ab_xy 0 5
-;ab[_[.ae.]]* ab 0 2
-;ab[_[.ae.]]* ab__ 0 4
-
-;ab[_[.ae.]]{2,5}xy ab__xy_ 0 6
-;ab[_[.ae.]]{2,5}xy ab____xy_ 0 8
-;ab[_[.ae.]]{2,5}xy ab_____xy_ 0 9
-;ab[_[.ae.]]{2,5}xy ab__xy 0 6
-;ab[_[.ae.]]{2,5}xy ab_____xy 0 9
-;ab[_[.ae.]]{2,5} ab__ 0 4
-;ab[_[.ae.]]{2,5} ab_______ 0 7
-;ab[_[.ae.]]{2,5}xy ab______xy -1 -1
-;ab[_[.ae.]]{2,5}xy ab_xy -1 -1
-
-;ab[_[.ae.]]*?xy abxy_ 0 4
-;ab[_[.ae.]]*?xy ab_xy_ 0 5
-;ab[_[.ae.]]*?xy abxy 0 4
-;ab[_[.ae.]]*?xy ab_xy 0 5
-;ab[_[.ae.]]*? ab 0 2
-;ab[_[.ae.]]*? ab__ 0 2
-
-;ab[_[.ae.]]{2,5}?xy ab__xy_ 0 6
-;ab[_[.ae.]]{2,5}?xy ab____xy_ 0 8
-;ab[_[.ae.]]{2,5}?xy ab_____xy_ 0 9
-;ab[_[.ae.]]{2,5}?xy ab__xy 0 6
-;ab[_[.ae.]]{2,5}?xy ab_____xy 0 9
-;ab[_[.ae.]]{2,5}? ab__ 0 4
-;ab[_[.ae.]]{2,5}? ab_______ 0 4
-;ab[_[.ae.]]{2,5}?xy ab______xy -1 -1
-;ab[_[.ae.]]{2,5}xy ab_xy -1 -1
-
-; new bugs detected in spring 2003:
-- normal match_continuous REG_NO_POSIX_TEST
-b abc 1 2
-
-() abc 0 0 0 0
-^() abc 0 0 0 0
-^()+ abc 0 0 0 0
-^(){1} abc 0 0 0 0
-^(){2} abc 0 0 0 0
-^((){2}) abc 0 0 0 0 0 0
-() "" 0 0 0 0
-()\1 "" 0 0 0 0
-()\1 a 0 0 0 0
-a()\1b ab 0 2 1 1
-a()b\1 ab 0 2 1 1
-
-; subtleties of matching with no sub-expressions marked
-- normal match_nosubs REG_NO_POSIX_TEST
-a(b?c)+d accd 0 4
-(wee|week)(knights|night) weeknights 0 10
-.* abc 0 3
-a(b|(c))d abd 0 3
-a(b|(c))d acd 0 3
-a(b*|c|e)d abbd 0 4
-a(b*|c|e)d acd 0 3
-a(b*|c|e)d ad 0 2
-a(b?)c abc 0 3
-a(b?)c ac 0 2
-a(b+)c abc 0 3
-a(b+)c abbbc 0 5
-a(b*)c ac 0 2
-(a|ab)(bc([de]+)f|cde) abcdef 0 6
-a([bc]?)c abc 0 3
-a([bc]?)c ac 0 2
-a([bc]+)c abc 0 3
-a([bc]+)c abcc 0 4
-a([bc]+)bc abcbc 0 5
-a(bb+|b)b abb 0 3
-a(bbb+|bb+|b)b abb 0 3
-a(bbb+|bb+|b)b abbb 0 4
-a(bbb+|bb+|b)bb abbb 0 4
-(.*).* abcdef 0 6
-(a*)* bc 0 0
-
-- normal nosubs REG_NO_POSIX_TEST
-a(b?c)+d accd 0 4
-(wee|week)(knights|night) weeknights 0 10
-.* abc 0 3
-a(b|(c))d abd 0 3
-a(b|(c))d acd 0 3
-a(b*|c|e)d abbd 0 4
-a(b*|c|e)d acd 0 3
-a(b*|c|e)d ad 0 2
-a(b?)c abc 0 3
-a(b?)c ac 0 2
-a(b+)c abc 0 3
-a(b+)c abbbc 0 5
-a(b*)c ac 0 2
-(a|ab)(bc([de]+)f|cde) abcdef 0 6
-a([bc]?)c abc 0 3
-a([bc]?)c ac 0 2
-a([bc]+)c abc 0 3
-a([bc]+)c abcc 0 4
-a([bc]+)bc abcbc 0 5
-a(bb+|b)b abb 0 3
-a(bbb+|bb+|b)b abb 0 3
-a(bbb+|bb+|b)b abbb 0 4
-a(bbb+|bb+|b)bb abbb 0 4
-(.*).* abcdef 0 6
-(a*)* bc 0 0
-
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 236714b..a71dce4 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1,23 +1,14 @@
CLEANFILES = tmp* core *.core $(EXTRA_PROGRAMS) *.*out *.log
TESTS = $(check_PROGRAMS) $(SEDTESTS)
-SEDTESTS =
-LDADD = ../lib/libsed.a
-noinst_HEADERS = testcases.h ptestcases.h
-AM_CPPFLAGS = -I../lib
+pcretest_LDADD = ../pcre/libpcre.a ../lib/libsed.a
+pcretest_DEPENDENCIES = ../pcre/libpcre.a ../lib/libsed.a
+check_PROGRAMS = pcretest
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_srcdir)/pcre
-if TEST_REGEX
-check_PROGRAMS = bug-regex7 \
- bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \
- bug-regex13 bug-regex14 bug-regex15 bug-regex16 \
- bug-regex21 tst-pcre tst-boost runtests runptests tst-rxspencer
-
-SEDTESTS += space
-endif
-
-SEDTESTS += \
- enable sep inclib 8bit newjis xabcx dollar noeol noeolw \
+SEDTESTS = \
+ space enable sep inclib 8bit newjis xabcx dollar noeol noeolw \
numsub numsub2 numsub3 numsub4 numsub5 0range bkslashes \
head madding mac-mf empty xbxcx xbxcx3 recall xemacs \
fasts uniq manis khadafy linecnt eval distrib 8to7 \
@@ -28,9 +19,10 @@ SEDTESTS += \
TESTS_ENVIRONMENT = MAKE="$(MAKE)" VERSION="$(VERSION)" $(srcdir)/runtest
-EXTRA_DIST = \
- PCRE.tests BOOST.tests SPENCER.tests \
- runtest Makefile.tests \
+EXTRA_DIST = runtest Makefile.tests \
+ pcre1.good pcre1.inp pcre1p.good \
+ pcre2.good pcre2.inp pcre2p.good \
+ pcre3.good pcre3.inp pcre3p.good \
0range.good 0range.inp 0range.sed \
8bit.good 8bit.inp 8bit.sed \
8to7.good 8to7.inp 8to7.sed \
diff --git a/testsuite/SPENCER.tests b/testsuite/SPENCER.tests
deleted file mode 100644
index f125523..0000000
--- a/testsuite/SPENCER.tests
+++ /dev/null
@@ -1,528 +0,0 @@
-# Copyright 1992, 1993, 1994, 1997 Henry Spencer. All rights reserved.
-# This software is not subject to any license of the American Telephone
-# and Telegraph Company or of the Regents of the University of California.
-#
-# Permission is granted to anyone to use this software for any purpose on
-# any computer system, and to alter it and redistribute it, subject
-# to the following restrictions:
-#
-# 1. The author is not responsible for the consequences of use of this
-# software, no matter how awful, even if they arise from flaws in it.
-#
-# 2. The origin of this software must not be misrepresented, either by
-# explicit claim or by omission. Since few users ever read sources,
-# credits must appear in the documentation.
-#
-# 3. Altered versions must be plainly marked as such, and must not be
-# misrepresented as being the original software. Since few users
-# ever read sources, credits must appear in the documentation.
-#
-# 4. This notice may not be removed or altered.
-#
-# regular expression test set
-# Lines are at least three fields, separated by one or more tabs. "" stands
-# for an empty field. First field is an RE. Second field is flags. If
-# C flag given, regcomp() is expected to fail, and the third field is the
-# error name (minus the leading REG_).
-#
-# Otherwise it is expected to succeed, and the third field is the string to
-# try matching it against. If there is no fourth field, the match is
-# expected to fail. If there is a fourth field, it is the substring that
-# the RE is expected to match. If there is a fifth field, it is a comma-
-# separated list of what the subexpressions should match, with - indicating
-# no match for that one. In both the fourth and fifth fields, a (sub)field
-# starting with @ indicates that the (sub)expression is expected to match
-# a null string followed by the stuff after the @; this provides a way to
-# test where null strings match. The character `N' in REs and strings
-# is newline, `S' is space, `T' is tab, `Z' is NUL.
-#
-# The full list of flags:
-# - placeholder, does nothing
-# b RE is a BRE, not an ERE
-# & try it as both an ERE and a BRE
-# C regcomp() error expected, third field is error name
-# i REG_ICASE
-# m ("mundane") REG_NOSPEC
-# s REG_NOSUB (not really testable)
-# n REG_NEWLINE
-# ^ REG_NOTBOL
-# $ REG_NOTEOL
-# # REG_STARTEND (see below)
-# p REG_PEND
-#
-# For REG_STARTEND, the start/end offsets are those of the substring
-# enclosed in ().
-
-# basics
-a & a a
-abc & abc abc
-abc|de - abc abc
-a|b|c - abc a
-
-# parentheses and perversions thereof
-a(b)c - abc abc
-a\(b\)c b abc abc
-a( C EPAREN
-a( b a( a(
-a\( - a( a(
-a\( bC EPAREN
-a\(b bC EPAREN
-a(b C EPAREN
-a(b b a(b a(b
-# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly)
-a) - a) a)
-) - ) )
-# end gagging (in a just world, those *should* give EPAREN)
-a) b a) a)
-a\) bC EPAREN
-\) bC EPAREN
-a()b - ab ab
-a\(\)b b ab ab
-
-# anchoring and REG_NEWLINE
-^abc$ & abc abc
-a^b - a^b
-a^b b a^b a^b
-a$b - a$b
-a$b b a$b a$b
-^ & abc @abc
-$ & abc @
-^$ & "" @
-$^ - "" @
-\($\)\(^\) b "" @
-# stop retching, those are legitimate (although disgusting)
-^^ - "" @
-$$ - "" @
-b$ & abNc
-b$ &n abNc b
-^b$ & aNbNc
-^b$ &n aNbNc b
-^$ &n aNNb @Nb
-^$ n abc
-^$ n abcN @
-$^ n aNNb @Nb
-\($\)\(^\) bn aNNb @Nb
-^^ n^ aNNb @Nb
-$$ n aNNb @NN
-^a ^ a
-a$ $ a
-^a ^n aNb
-^b ^n aNb b
-a$ $n bNa
-b$ $n bNa b
-a*(^b$)c* - b b
-a*\(^b$\)c* b b b
-
-# certain syntax errors and non-errors
-| C EMPTY
-| b | |
-* C BADRPT
-* b * *
-+ C BADRPT
-? C BADRPT
-"" &C EMPTY
-() - abc @abc
-\(\) b abc @abc
-a||b C EMPTY
-|ab C EMPTY
-ab| C EMPTY
-(|a)b C EMPTY
-(a|)b C EMPTY
-(*a) C BADRPT
-(+a) C BADRPT
-(?a) C BADRPT
-({1}a) C BADRPT
-\(\{1\}a\) bC BADRPT
-(a|*b) C BADRPT
-(a|+b) C BADRPT
-(a|?b) C BADRPT
-(a|{1}b) C BADRPT
-^* C BADRPT
-^* b * *
-^+ C BADRPT
-^? C BADRPT
-^{1} C BADRPT
-^\{1\} bC BADRPT
-
-# metacharacters, backslashes
-a.c & abc abc
-a[bc]d & abd abd
-a\*c & a*c a*c
-a\\b & a\b a\b
-a\\\*b & a\*b a\*b
-# The following test is wrong. Using \b in an BRE or ERE is undefined.
-# a\bc & abc abc
-a\ &C EESCAPE
-a\\bc & a\bc a\bc
-\{ bC BADRPT
-a\[b & a[b a[b
-a[b &C EBRACK
-# trailing $ is a peculiar special case for the BRE code
-a$ & a a
-a$ & a$
-a\$ & a
-a\$ & a$ a$
-a\\$ & a
-a\\$ & a$
-a\\$ & a\$
-a\\$ & a\ a\
-
-# back references, ugh
-a\(b\)\2c bC ESUBREG
-a\(b\1\)c bC ESUBREG
-a\(b*\)c\1d b abbcbbd abbcbbd bb
-a\(b*\)c\1d b abbcbd
-a\(b*\)c\1d b abbcbbbd
-^\(.\)\1 b abc
-a\([bc]\)\1d b abcdabbd abbd b
-a\(\([bc]\)\2\)*d b abbccd abbccd
-a\(\([bc]\)\2\)*d b abbcbd
-# actually, this next one probably ought to fail, but the spec is unclear
-a\(\(b\)*\2\)*d b abbbd abbbd
-# here is a case that no NFA implementation does right
-\(ab*\)[ab]*\1 b ababaaa ababaaa a
-# check out normal matching in the presence of back refs
-\(a\)\1bcd b aabcd aabcd
-\(a\)\1bc*d b aabcd aabcd
-\(a\)\1bc*d b aabd aabd
-\(a\)\1bc*d b aabcccd aabcccd
-\(a\)\1bc*[ce]d b aabcccd aabcccd
-^\(a\)\1b\(c\)*cd$ b aabcccd aabcccd
-
-# ordinary repetitions
-ab*c & abc abc
-ab+c - abc abc
-ab?c - abc abc
-a\(*\)b b a*b a*b
-a\(**\)b b ab ab
-a\(***\)b bC BADRPT
-*a b *a *a
-**a b a a
-***a bC BADRPT
-
-# the dreaded bounded repetitions
-# The following two tests are not correct:
-#{ & { {
-#{abc & {abc {abc
-# '{' is always a special char outside bracket expressions. So test ony BRE:
-{ b { {
-{abc b {abc {abc
-{1 C BADRPT
-{1} C BADRPT
-# Same reason as for the two tests above:
-#a{b & a{b a{b
-a{b b a{b a{b
-a{1}b - ab ab
-a\{1\}b b ab ab
-a{1,}b - ab ab
-a\{1,\}b b ab ab
-a{1,2}b - aab aab
-a\{1,2\}b b aab aab
-a{1 C EBRACE
-a\{1 bC EBRACE
-a{1a C EBRACE
-a\{1a bC EBRACE
-a{1a} C BADBR
-a\{1a\} bC BADBR
-# These four tests checks for undefined behavior. Our implementation does
-# something different.
-#a{,2} - a{,2} a{,2}
-#a\{,2\} bC BADBR
-#a{,} - a{,} a{,}
-#a\{,\} bC BADBR
-a{1,x} C BADBR
-a\{1,x\} bC BADBR
-a{1,x C EBRACE
-a\{1,x bC EBRACE
-# These two tests probably fails due to an arbitrary limit on the number of
-# repetitions in the other implementation.
-#a{300} C BADBR
-#a\{300\} bC BADBR
-a{1,0} C BADBR
-a\{1,0\} bC BADBR
-ab{0,0}c - abcac ac
-ab\{0,0\}c b abcac ac
-ab{0,1}c - abcac abc
-ab\{0,1\}c b abcac abc
-ab{0,3}c - abbcac abbc
-ab\{0,3\}c b abbcac abbc
-ab{1,1}c - acabc abc
-ab\{1,1\}c b acabc abc
-ab{1,3}c - acabc abc
-ab\{1,3\}c b acabc abc
-ab{2,2}c - abcabbc abbc
-ab\{2,2\}c b abcabbc abbc
-ab{2,4}c - abcabbc abbc
-ab\{2,4\}c b abcabbc abbc
-((a{1,10}){1,10}){1,10} - a a a,a
-
-# multiple repetitions
-# Wow, there is serious disconnect here. The ERE grammar is like this:
-# ERE_expression : one_char_or_coll_elem_ERE
-# | '^'
-# | '$'
-# | '(' extended_reg_exp ')'
-# | ERE_expression ERE_dupl_symbol
-# ;
-# where ERE_dupl_symbol is any of the repetition methods. It is clear from
-# this that consecutive repetition is OK. On top of this, the one test not
-# marked as failing must fail. For BREs the situation is different, so we
-# use the four tests.
-#a** &C BADRPT
-a** bC BADRPT
-#a++ C BADRPT
-#a?? C BADRPT
-#a*+ C BADRPT
-#a*? C BADRPT
-#a+* C BADRPT
-#a+? C BADRPT
-#a?* C BADRPT
-#a?+ C BADRPT
-#a{1}{1} C BADRPT
-#a*{1} C BADRPT
-#a+{1} C BADRPT
-#a?{1} C BADRPT
-#a{1}* C BADRPT
-#a{1}+ C BADRPT
-#a{1}? C BADRPT
-#a*{b} - a{b} a{b}
-a\{1\}\{1\} bC BADRPT
-a*\{1\} bC BADRPT
-a\{1\}* bC BADRPT
-
-# brackets, and numerous perversions thereof
-a[b]c & abc abc
-a[ab]c & abc abc
-a[^ab]c & adc adc
-a[]b]c & a]c a]c
-a[[b]c & a[c a[c
-a[-b]c & a-c a-c
-a[^]b]c & adc adc
-a[^-b]c & adc adc
-a[b-]c & a-c a-c
-a[b &C EBRACK
-a[] &C EBRACK
-a[1-3]c & a2c a2c
-a[3-1]c &C ERANGE
-a[1-3-5]c &C ERANGE
-a[[.-.]--]c & a-c a-c
-# I don't thing the error value should be ERANGE since a[1-] would be
-# valid, too. Expect EBRACK.
-#a[1- &C ERANGE
-a[1- &C EBRACK
-a[[. &C EBRACK
-a[[.x &C EBRACK
-a[[.x. &C EBRACK
-a[[.x.] &C EBRACK
-a[[.x.]] & ax ax
-a[[.x,.]] &C ECOLLATE
-# This test is invalid. "one" is no collating symbol in any standardized
-# locale.
-# a[[.one.]]b & a1b a1b
-a[[.notdef.]]b &C ECOLLATE
-a[[.].]]b & a]b a]b
-a[[:alpha:]]c & abc abc
-a[[:notdef:]]c &C ECTYPE
-a[[: &C EBRACK
-a[[:alpha &C EBRACK
-a[[:alpha:] &C EBRACK
-a[[:alpha,:] &C ECTYPE
-a[[:]:]]b &C ECTYPE
-a[[:-:]]b &C ECTYPE
-a[[:alph:]] &C ECTYPE
-a[[:alphabet:]] &C ECTYPE
-[[:alnum:]]+ - -%@a0X- a0X
-[[:alpha:]]+ - -%@aX0- aX
-[[:blank:]]+ - aSSTb SST
-[[:cntrl:]]+ - aNTb NT
-[[:digit:]]+ - a019b 019
-[[:graph:]]+ - Sa%bS a%b
-[[:lower:]]+ - AabC ab
-[[:print:]]+ - NaSbN aSb
-[[:punct:]]+ - S%-&T %-&
-[[:space:]]+ - aSNTb SNT
-[[:upper:]]+ - aBCd BC
-[[:xdigit:]]+ - p0f3Cq 0f3C
-a[[=b=]]c & abc abc
-a[[= &C EBRACK
-a[[=b &C EBRACK
-a[[=b= &C EBRACK
-a[[=b=] &C EBRACK
-a[[=b,=]] &C ECOLLATE
-# This test is invalid. "one" is no collating symbol in any standardized
-# locale.
-#a[[=one=]]b & a1b a1b
-
-# complexities
-a(((b)))c - abc abc
-a(b|(c))d - abd abd
-a(b*|c)d - abbd abbd
-# just gotta have one DFA-buster, of course
-a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
-# and an inline expansion in case somebody gets tricky
-a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
-# and in case somebody just slips in an NFA...
-a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights
-# fish for anomalies as the number of states passes 32
-12345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789
-123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890
-1234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901
-12345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012
-123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123
-# and one really big one, beyond any plausible word width
-1234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890
-# fish for problems as brackets go past 8
-[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm
-[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo
-[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq
-[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq
-
-# subtleties of matching
-abc & xabcy abc
-a\(b\)?c\1d b acd
-aBc i Abc Abc
-a[Bc]*d i abBCcd abBCcd
-0[[:upper:]]1 &i 0a1 0a1
-0[[:lower:]]1 &i 0A1 0A1
-a[^b]c &i abc
-a[^b]c &i aBc
-a[^b]c &i adc adc
-[a]b[c] - abc abc
-[a]b[a] - aba aba
-[abc]b[abc] - abc abc
-[abc]b[abd] - abd abd
-a(b?c)+d - accd accd
-(wee|week)(knights|night) - weeknights weeknights
-(we|wee|week|frob)(knights|night|day) - weeknights weeknights
-a[bc]d - xyzaaabcaababdacd abd
-a[ab]c - aaabc abc
-abc s abc abc
-a* & b @b
-
-# Let's have some fun -- try to match a C comment.
-# first the obvious, which looks okay at first glance...
-/\*.*\*/ - /*x*/ /*x*/
-# but...
-/\*.*\*/ - /*x*/y/*z*/ /*x*/y/*z*/
-# okay, we must not match */ inside; try to do that...
-/\*([^*]|\*[^/])*\*/ - /*x*/ /*x*/
-/\*([^*]|\*[^/])*\*/ - /*x*/y/*z*/ /*x*/
-# but...
-/\*([^*]|\*[^/])*\*/ - /*x**/y/*z*/ /*x**/y/*z*/
-# and a still fancier version, which does it right (I think)...
-/\*([^*]|\*+[^*/])*\*+/ - /*x*/ /*x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x*/y/*z*/ /*x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x**/y/*z*/ /*x**/
-/\*([^*]|\*+[^*/])*\*+/ - /*x****/y/*z*/ /*x****/
-/\*([^*]|\*+[^*/])*\*+/ - /*x**x*/y/*z*/ /*x**x*/
-/\*([^*]|\*+[^*/])*\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/
-
-# subexpressions
-.* - abc abc -
-a(b)(c)d - abcd abcd b,c
-a(((b)))c - abc abc b,b,b
-a(b|(c))d - abd abd b,-
-a(b*|c|e)d - abbd abbd bb
-a(b*|c|e)d - acd acd c
-a(b*|c|e)d - ad ad @d
-a(b?)c - abc abc b
-a(b?)c - ac ac @c
-a(b+)c - abc abc b
-a(b+)c - abbbc abbbc bbb
-a(b*)c - ac ac @c
-(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de
-# the regression tester only asks for 9 subexpressions
-a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j
-a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k
-a([bc]?)c - abc abc b
-a([bc]?)c - ac ac @c
-a([bc]+)c - abc abc b
-a([bc]+)c - abcc abcc bc
-a([bc]+)bc - abcbc abcbc bc
-a(bb+|b)b - abb abb b
-a(bbb+|bb+|b)b - abb abb b
-a(bbb+|bb+|b)b - abbb abbb bb
-a(bbb+|bb+|b)bb - abbb abbb b
-(.*).* - abcdef abcdef abcdef
-(a*)* - bc @b @b
-
-# do we get the right subexpression when it is used more than once?
-a(b|c)*d - ad ad -
-a(b|c)*d - abcd abcd c
-a(b|c)+d - abd abd b
-a(b|c)+d - abcd abcd c
-a(b|c?)+d - ad ad @d
-a(b|c?)+d - abcd abcd c
-a(b|c){0,0}d - ad ad -
-a(b|c){0,1}d - ad ad -
-a(b|c){0,1}d - abd abd b
-a(b|c){0,2}d - ad ad -
-a(b|c){0,2}d - abcd abcd c
-a(b|c){0,}d - ad ad -
-a(b|c){0,}d - abcd abcd c
-a(b|c){1,1}d - abd abd b
-a(b|c){1,1}d - acd acd c
-a(b|c){1,2}d - abd abd b
-a(b|c){1,2}d - abcd abcd c
-a(b|c){1,}d - abd abd b
-a(b|c){1,}d - abcd abcd c
-a(b|c){2,2}d - acbd acbd b
-a(b|c){2,2}d - abcd abcd c
-a(b|c){2,4}d - abcd abcd c
-a(b|c){2,4}d - abcbd abcbd b
-a(b|c){2,4}d - abcbcd abcbcd c
-a(b|c){2,}d - abcd abcd c
-a(b|c){2,}d - abcbd abcbd b
-a(b+|((c)*))+d - abd abd b,-,-
-a(b+|((c)*))+d - abcd abcd c,c,c
-
-# check out the STARTEND option
-[abc] a(b)c b
-[abc] a(d)c
-[abc] a(bc)d b
-[abc] a(dc)d c
-. a()c
-b.*c b(bc)c bc
-b.* b(bc)c bc
-.*c b(bc)c bc
-
-# plain strings, with the NOSPEC flag
-abc m abc abc
-abc m xabcy abc
-abc m xyz
-a*b m aba*b a*b
-a*b m ab
-"" mC EMPTY
-
-# cases involving NULs
-aZb & a a
-aZb &p a
-aZb &p# (aZb) aZb
-aZ*b &p# (ab) ab
-a.b (aZb) aZb
-a.* (aZb)c aZb
-
-# word boundaries (ick)
-[[:<:]]a & a a
-[[:<:]]a & ba
-[[:<:]]a & -a a
-a[[:>:]] & a a
-a[[:>:]] & ab
-a[[:>:]] & a- a
-[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc
-[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc
-[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc
-[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc
-[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_
-[[:<:]]a_b[[:>:]] & x_a_b
-
-# past problems, and suspected problems
-(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1
-abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop
-abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv
-(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11
-CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11
-Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz
-a?b - ab ab
--\{0,1\}[0-9]*$ b -5 -5
-a*a*a*a*a*a*a* & aaaaaa aaaaaa
diff --git a/testsuite/bug-regex10.c b/testsuite/bug-regex10.c
deleted file mode 100644
index 5cb0146..0000000
--- a/testsuite/bug-regex10.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Test for re_match with non-zero start.
- Copyright (C) 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek , 2002.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include
-#include
-#include
-#include
-
-int
-main (void)
-{
- struct re_pattern_buffer regex;
- struct re_registers regs;
- const char *s;
- int match;
- int result = 0;
-
- regs.num_regs = 1;
- memset (®ex, '\0', sizeof (regex));
- s = re_compile_pattern ("[abc]*d", 7, ®ex);
- if (s != NULL)
- {
- puts ("re_compile_pattern return non-NULL value");
- result = 1;
- }
- else
- {
- match = re_match (®ex, "foacabdxy", 9, 2, ®s);
- if (match != 5)
- {
- printf ("re_match returned %d, expected 5\n", match);
- result = 1;
- }
- else if (regs.start[0] != 2 || regs.end[0] != 7)
- {
- printf ("re_match returned %d..%d, expected 2..7\n",
- regs.start[0], regs.end[0]);
- result = 1;
- }
- puts (" -> OK");
- }
-
- return result;
-}
diff --git a/testsuite/bug-regex11.c b/testsuite/bug-regex11.c
deleted file mode 100644
index 29fa7de..0000000
--- a/testsuite/bug-regex11.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Regular expression tests.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek , 2002.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include
-#include
-#include
-#include
-#include
-
-/* Tests supposed to match. */
-struct
-{
- const char *pattern;
- const char *string;
- int flags, nmatch;
- regmatch_t rm[5];
-} tests[] = {
- /* Test for newline handling in regex. */
- { "[^~]*~", "\nx~y", 0, 2, { { 0, 3 }, { -1, -1 } } },
- /* Other tests. */
- { "a(.*)b", "a b", REG_EXTENDED, 2, { { 0, 3 }, { 1, 2 } } },
- { ".*|\\([KIO]\\)\\([^|]*\\).*|?[KIO]", "10~.~|P|K0|I10|O16|?KSb", 0, 3,
- { { 0, 21 }, { 15, 16 }, { 16, 18 } } },
- { ".*|\\([KIO]\\)\\([^|]*\\).*|?\\1", "10~.~|P|K0|I10|O16|?KSb", 0, 3,
- { { 0, 21 }, { 8, 9 }, { 9, 10 } } },
- { "^\\(a*\\)\\1\\{9\\}\\(a\\{0,9\\}\\)\\([0-9]*;.*[^a]\\2\\([0-9]\\)\\)",
- "a1;;0a1aa2aaa3aaaa4aaaaa5aaaaaa6aaaaaaa7aaaaaaaa8aaaaaaaaa9aa2aa1a0", 0,
- 5, { { 0, 67 }, { 0, 0 }, { 0, 1 }, { 1, 67 }, { 66, 67 } } },
- /* Test for BRE expression anchoring. POSIX says just that this may match;
- in glibc regex it always matched, so avoid changing it. */
- { "\\(^\\|foo\\)bar", "bar", 0, 2, { { 0, 3 }, { -1, -1 } } },
- { "\\(foo\\|^\\)bar", "bar", 0, 2, { { 0, 3 }, { -1, -1 } } },
- /* In ERE this must be treated as an anchor. */
- { "(^|foo)bar", "bar", REG_EXTENDED, 2, { { 0, 3 }, { -1, -1 } } },
- { "(foo|^)bar", "bar", REG_EXTENDED, 2, { { 0, 3 }, { -1, -1 } } },
- /* Here ^ cannot be treated as an anchor according to POSIX. */
- { "(^|foo)bar", "(^|foo)bar", 0, 2, { { 0, 10 }, { -1, -1 } } },
- { "(foo|^)bar", "(foo|^)bar", 0, 2, { { 0, 10 }, { -1, -1 } } },
- /* More tests on backreferences. */
- { "()\\1", "x", REG_EXTENDED, 2, { { 0, 0 }, { 0, 0 } } },
- { "()x\\1", "x", REG_EXTENDED, 2, { { 0, 1 }, { 0, 0 } } },
- { "()\\1*\\1*", "", REG_EXTENDED, 2, { { 0, 0 }, { 0, 0 } } },
- { "([0-9]).*\\1(a*)", "7;7a6", REG_EXTENDED, 3, { { 0, 4 }, { 0, 1 }, { 3, 4 } } },
- { "([0-9]).*\\1(a*)", "7;7a", REG_EXTENDED, 3, { { 0, 4 }, { 0, 1 }, { 3, 4 } } },
- { "(b)()c\\1", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 1 }, { 1, 1 } } },
- { "()(b)c\\2", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 0 }, { 0, 1 } } },
- { "a(b)()c\\1", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 2 }, { 2, 2 } } },
- { "a()(b)c\\2", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 1 }, { 1, 2 } } },
- { "()(b)\\1c\\2", "bcb", REG_EXTENDED, 3, { { 0, 3 }, { 0, 0 }, { 0, 1 } } },
- { "(b())\\2\\1", "bbbb", REG_EXTENDED, 3, { { 0, 2 }, { 0, 1 }, { 1, 1 } } },
- { "a()(b)\\1c\\2", "abcb", REG_EXTENDED, 3, { { 0, 4 }, { 1, 1 }, { 1, 2 } } },
- { "a()d(b)\\1c\\2", "adbcb", REG_EXTENDED, 3, { { 0, 5 }, { 1, 1 }, { 2, 3 } } },
- { "a(b())\\2\\1", "abbbb", REG_EXTENDED, 3, { { 0, 3 }, { 1, 2 }, { 2, 2 } } },
- { "(bb())\\2\\1", "bbbb", REG_EXTENDED, 3, { { 0, 4 }, { 0, 2 }, { 2, 2 } } },
- { "^(.?)(.?)(.?)(.?)(.?).?\\5\\4\\3\\2\\1$",
- "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } },
- { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$",
- "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } },
- { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$",
- "abcdedcba", REG_EXTENDED, 1, { { 0, 9 } } },
-#if 0
- /* XXX Not used since they fail so far. */
- { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$|^.?$",
- "ababababa", REG_EXTENDED, 1, { { 0, 9 } } },
- { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$",
- "level", REG_NOSUB | REG_EXTENDED, 0, { { -1, -1 } } },
- { "^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\\9\\8\\7\\6\\5\\4\\3\\2\\1$",
- "ababababa", REG_EXTENDED, 1, { { 0, 9 } } },
-#endif
-};
-
-int
-main (void)
-{
- regex_t re;
- regmatch_t rm[5];
- size_t i;
- int n, ret = 0;
-
- mtrace ();
-
- for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
- {
- n = regcomp (&re, tests[i].pattern, tests[i].flags);
- if (n != 0)
- {
- char buf[500];
- regerror (n, &re, buf, sizeof (buf));
- printf ("%s: regcomp %zd failed: %s\n", tests[i].pattern, i, buf);
- ret = 1;
- continue;
- }
-
- if (regexec (&re, tests[i].string, tests[i].nmatch, rm, 0))
- {
- printf ("%s: regexec %zd failed\n", tests[i].pattern, i);
- ret = 1;
- regfree (&re);
- continue;
- }
-
- for (n = 0; n < tests[i].nmatch; ++n)
- if (rm[n].rm_so != tests[i].rm[n].rm_so
- || rm[n].rm_eo != tests[i].rm[n].rm_eo)
- {
- if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1)
- break;
- printf ("%s: regexec %zd match failure rm[%d] %d..%d\n",
- tests[i].pattern, i, n, rm[n].rm_so, rm[n].rm_eo);
- ret = 1;
- break;
- }
-
- regfree (&re);
- }
-
- return ret;
-}
diff --git a/testsuite/bug-regex12.c b/testsuite/bug-regex12.c
deleted file mode 100644
index 0ad063e..0000000
--- a/testsuite/bug-regex12.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Regular expression tests.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek , 2002.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include