From ffe1f41595f39a24aab5f83829dcb8ea3c423238 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Wed, 18 Aug 2010 00:11:33 +0100
Subject: [PATCH 2/2] Document syntax flags better.

regex.texi: Add documentation for missing syntax flags.

regex.h: correct and clarify documentation for RE_CONTEXT_INVALID_DUP

Remove commented-out documentation of defunct syntax option
RE_NO_EMPTY_ALTS.

Correct name of RE_CHAR_CLASSES in one incorrect occurrence.
---
 doc/regex.texi |   84 ++++++++++++++++++++++++++++++++++----------------------
 lib/regex.h    |    4 +-
 2 files changed, 53 insertions(+), 35 deletions(-)

diff --git a/doc/regex.texi b/doc/regex.texi
index 59dfd8b..5147e7a 100644
--- a/doc/regex.texi
+++ b/doc/regex.texi
@@ -159,6 +159,12 @@ open-group or alternation operator.  The same holds for @samp{@{} (or
 it is the beginning of a valid interval and the syntax bit
 @code{RE_INTERVALS} is set.
 
+@cnindex RE_CONTEXT_INVALID_DUP
+@item RE_CONTEXT_INVALID_DUP
+If this bit is set, then an open-interval operator cannot occur at the
+start of a regular expression, or immediately after an alternation,
+open-group or close-interval operator.
+
 @cnindex RE_CONTEXT_INVALID_OPS
 @item RE_CONTEXT_INVALID_OPS
 If this bit is set, then repetition and alternation operators can't be
@@ -183,6 +189,12 @@ repetition and alternation characters anywhere in a regular expression.
 Whether or not they will in fact be operators in certain positions
 depends on other syntax bits.
 
+@cnindex RE_DEBUG
+@item RE_DEBUG
+If this bit is set, and the regex library was compiled with
+@code{-DDEBUG}, then internal debugging is turned on; if unset, then
+it is turned off.
+
 @cnindex RE_DOT_NEWLINE
 @item RE_DOT_NEWLINE
 If this bit is set, then the match-any-character operator matches
@@ -193,11 +205,27 @@ a newline; if this bit isn't set, then it doesn't.
 If this bit is set, then the match-any-character operator doesn't match
 a null character; if this bit isn't set, then it does.
 
+@cnindex RE_HAT_LISTS_NOT_NEWLINE
+@item RE_HAT_LISTS_NOT_NEWLINE
+If this bit is set, nonmatching lists @samp{[^...]} do not match
+newline; if not set, they do.
+
+@cnindex RE_ICASE
+@item RE_ICASE
+If this bit is set, then ignore case when matching; otherwise, case is
+significant.
+
 @cnindex RE_INTERVALS
 @item RE_INTERVALS
 If this bit is set, then Regex recognizes interval operators; if this bit
 isn't set, then it doesn't.
 
+@cnindex RE_INVALID_INTERVAL_ORD
+@item RE_INVALID_INTERVAL_ORD
+If this bit is set, a syntactically invalid interval is treated as a
+string of ordinary characters.  For example, the extended regular
+expression @samp{a{1} is treated as @samp{a\{1}.
+
 @cnindex RE_LIMITED_OPS
 @item RE_LIMITED_OPS
 If this bit is set, then Regex doesn't recognize the match-one-or-more,
@@ -241,6 +269,22 @@ If this bit is set, then a regular expression with a range whose ending
 point collates lower than its starting point is invalid; if this bit
 isn't set, then Regex considers such a range to be empty.
 
+@cnindex RE_NO_GNU_OPS
+@item RE_NO_GNU_OPS
+If this bit is set, GNU regex operators are not recognized; otherwise,
+they are.
+
+@cnindex RE_NO_POSIX_BACKTRACKING
+@item RE_NO_POSIX_BACKTRACKING
+If this bit is set, succeed as soon as we match the whole pattern,
+without further backtracking.  This means that a match may not be
+the leftmost longest; @pxref{What Gets Matched?} for what this means.
+
+@cnindex RE_NO_SUB
+@item RE_NO_SUB
+If this bit is set, then @code{no_sub} will be set to one during
+@code{re_compile_pattern}; @pxref{POSIX Matching}, for what this means.
+
 @cnindex RE_UNMATCHED_RIGHT_PAREN_ORD
 @item RE_UNMATCHED_RIGHT_PAREN_ORD
 If this bit is set and the regular expression has no matching open-group
@@ -713,32 +757,6 @@ example, supposing that @samp{|} is the alternation operator, then
 @samp{foo|bar|quux} would match any of @samp{foo}, @samp{bar} or
 @samp{quux}.
 
-@ignore
-@c Nobody needs to disallow empty alternatives any more.
-If the syntax bit @code{RE_NO_EMPTY_ALTS} is set, then if either of the regular
-expressions @var{a} or @var{b} is empty, the
-regular expression is invalid.  More precisely, if this syntax bit is
-set, then the alternation operator can't:
-
-@itemize @bullet
-@item
-be first or last in a regular expression;
-
-@item
-follow either another alternation operator or an open-group operator
-(@pxref{Grouping Operators}); or
-
-@item
-precede a close-group operator.
-
-@end itemize
-
-@noindent
-For example, supposing @samp{(} and @samp{)} represent the open and
-close-group operators, then @samp{|foo}, @samp{foo|}, @samp{foo||bar},
-@samp{foo(|bar)}, and @samp{(foo|)bar} would all be invalid.
-@end ignore
-
 The alternation operator operates on the @emph{largest} possible
 surrounding regular expressions.  (Put another way, it has the lowest
 precedence of any regular expression operator.)
@@ -908,13 +926,13 @@ symbol.
 @cindex @samp{[:} in regex
 @cindex @samp{:]} in regex
 
-If the syntax bit @code{RE_CHARACTER_CLASSES} is set, then Regex
-recognizes character class expressions inside lists.  A @dfn{character
-class expression} matches one character from a given class.  You form a
-character class expression by putting a character class name between an
-@dfn{open-character-class operator} (represented by @samp{[:}) and a
-@dfn{close-character-class operator} (represented by @samp{:]}).  The
-character class names and their meanings are:
+If the syntax bit @code{RE_CHAR_CLASSES} is set, then Regex recognizes
+character class expressions inside lists.  A @dfn{character class
+expression} matches one character from a given class.  You form a
+character class expression by putting a character class name between
+an @dfn{open-character-class operator} (represented by @samp{[:}) and
+a @dfn{close-character-class operator} (represented by @samp{:]}).
+The character class names and their meanings are:
 
 @table @code
 
diff --git a/lib/regex.h b/lib/regex.h
index a239c31..053e612 100644
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -219,8 +219,8 @@ typedef unsigned long int reg_syntax_t;
    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.  */
+/* If this bit is set, then \{ cannot be first in a regex or
+   immediately after an alternation, open-group or \} operator.  */
 # define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
 
 /* If this bit is set, then no_sub will be set to 1 during
-- 
1.7.1

