From d1fb15ba12436afdd742eaff1ec46f75ee397bda Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 1 Aug 2010 18:47:14 +0200 Subject: [PATCH] Integrate the regex documentation. --- ChangeLog | 7 + doc/gnulib.texi | 46 +++- doc/regex.texi | 737 +++++--------------------------------------------------- 3 files changed, 105 insertions(+), 685 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2885173e2..4d24a34fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2010-08-01 Bruno Haible + Integrate the regex documentation. + * doc/gnulib.texi: Define 'cn' index. + (Regular expressions): New a chapter that includes regex.texi and + regexprops-generic.texi. + * doc/regex.texi: Remove boilerplate stuff. Use simplified @node + syntax. + Whitespace cleanup. * doc/regex.texi: Remove trailing spaces. diff --git a/doc/gnulib.texi b/doc/gnulib.texi index a1f54461c..ee04e2a75 100644 --- a/doc/gnulib.texi +++ b/doc/gnulib.texi @@ -2,8 +2,14 @@ @comment %**start of header @setfilename gnulib.info @settitle GNU Gnulib +@c Define a new index for the magic constants in regex.texi. +@defcodeindex cn @syncodeindex fn cp +@syncodeindex ky cp @syncodeindex pg cp +@syncodeindex tp cp +@syncodeindex vr cp +@syncodeindex cn cp @ifclear texi2html @firstparagraphindent insert @end ifclear @@ -63,6 +69,7 @@ Documentation License''. * Glibc Header File Substitutes:: Overriding system headers. * Glibc Function Substitutes:: Replacing system functions. * Particular Modules:: Documentation of individual modules. +* Regular expressions:: The regex module. * GNU Free Documentation License:: Copying and sharing this manual. * Index:: @end menu @@ -6486,7 +6493,6 @@ This list of functions is sorted according to the header that declares them. * Quoting:: * error and progname:: * gcd:: -* Regular expressions:: * Searching for Libraries:: * Exported Symbols of Shared Libraries:: * LD Version Scripts:: @@ -6568,16 +6574,6 @@ ASCII characters. @include gcd.texi -@node Regular expressions -@section Regular expressions - -Gnulib supports many different types of regular expressions; although -the underlying features are the same or identical, the syntax used -varies. The descriptions given here for the different types are -generated automatically. - -@include regexprops-generic.texi - @include havelib.texi @include lib-symbol-visibility.texi @@ -6596,6 +6592,34 @@ generated automatically. @include valgrind-tests.texi +@node Regular expressions +@chapter Regular expressions + +@menu +* Overview:: +* Regular Expression Syntax:: +* Common Operators:: +* GNU Operators:: +* GNU Emacs Operators:: +* What Gets Matched?:: +* Programming with Regex:: +* Regular expression syntaxes:: +@end menu + +@lowersections +@include regex.texi +@raisesections + +@node Regular expression syntaxes +@section Regular expression syntaxes + +Gnulib supports many different types of regular expressions; although +the underlying features are the same or identical, the syntax used +varies. The descriptions given here for the different types are +generated automatically. + +@include regexprops-generic.texi + @node GNU Free Documentation License @appendix GNU Free Documentation License diff --git a/doc/regex.texi b/doc/regex.texi index e25efa464..2c0e9d23b 100644 --- a/doc/regex.texi +++ b/doc/regex.texi @@ -1,213 +1,4 @@ -\input texinfo -@c %**start of header -@setfilename regex.info -@settitle Regex -@c %**end of header - -@c \\{fill-paragraph} works better (for me, anyway) if the text in the -@c source file isn't indented. -@paragraphindent 2 - -@c Define a new index for our magic constants. -@defcodeindex cn - -@c Put everything in one index (arbitrarily chosen to be the concept index). -@syncodeindex cn cp -@syncodeindex ky cp -@syncodeindex pg cp -@syncodeindex tp cp -@syncodeindex vr cp - -@c Here is what we use in the Info `dir' file: -@c * Regex: (regex). Regular expression library. - - -@ifinfo -This file documents the GNU regular expression library. - -Copyright (C) 1992, 1993 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries a copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo - - -@titlepage - -@title Regex -@subtitle edition 0.12a -@subtitle 19 September 1992 -@author Kathryn A. Hargreaves -@author Karl Berry - -@page - -@vskip 0pt plus 1filll -Copyright @copyright{} 1992 Free Software Foundation. - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. - -@end titlepage - - -@ifinfo -@node Top, Overview, (dir), (dir) -@top Regular Expression Library - -This manual documents how to program with the GNU regular expression -library. This is edition 0.12a of the manual, 19 September 1992. - -The first part of this master menu lists the major nodes in this Info -document, including the index. The rest of the menu lists all the -lower level nodes in the document. - -@menu -* Overview:: -* Regular Expression Syntax:: -* Common Operators:: -* GNU Operators:: -* GNU Emacs Operators:: -* What Gets Matched?:: -* Programming with Regex:: -* Copying:: Copying and sharing Regex. -* Index:: General index. - --- The Detailed Node Listing --- - -Regular Expression Syntax - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - -Common Operators - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - -Repetition Operators - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} - -List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - -Anchoring Operators - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - -GNU Operators - -* Word Operators:: -* Buffer Operators:: - -Word Operators - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - -Buffer Operators - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - -GNU Emacs Operators - -* Syntactic Class Operators:: - -Syntactic Class Operators - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - -Programming with Regex - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - -GNU Regex Functions - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - -POSIX Regex Functions - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - -BSD Regex Functions - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu -@end ifinfo -@node Overview, Regular Expression Syntax, Top, Top +@node Overview @chapter Overview A @dfn{regular expression} (or @dfn{regexp}, or @dfn{pattern}) is a text @@ -263,7 +54,7 @@ library in its entirety, not how to write regular expressions that a particular program understands. -@node Regular Expression Syntax, Common Operators, Overview, Top +@node Regular Expression Syntax @chapter Regular Expression Syntax @cindex regular expressions, syntax of @@ -301,7 +92,7 @@ In the following sections, we describe these things in more detail. @end menu -@node Syntax Bits, Predefined Syntaxes, , Regular Expression Syntax +@node Syntax Bits @section Syntax Bits @cindex syntax bits @@ -461,7 +252,7 @@ operator (based on how @code{RE_NO_BK_PARENS} is set) to match @samp{)}. @end table -@node Predefined Syntaxes, Collating Elements vs. Characters, Syntax Bits, Regular Expression Syntax +@node Predefined Syntaxes @section Predefined Syntaxes If you're programming with Regex, you can set a pattern buffer's @@ -543,7 +334,7 @@ The predefined syntaxes--taken directly from @file{regex.h}---are: | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) @end example -@node Collating Elements vs. Characters, The Backslash Character, Predefined Syntaxes, Regular Expression Syntax +@node Collating Elements vs. Characters @section Collating Elements vs.@: Characters @sc{posix} generalizes the notion of a character to that of a @@ -568,7 +359,7 @@ collating element. For example, the Spanish @samp{ll} collates after Since @sc{posix}'s ``collating element'' preserves the essential idea of a ``character,'' we use the latter, more familiar, term in this document. -@node The Backslash Character, , Collating Elements vs. Characters, Regular Expression Syntax +@node The Backslash Character @section The Backslash Character @cindex \ @@ -659,7 +450,7 @@ In all other cases, Regex ignores @samp{\}. For example, @end enumerate -@node Common Operators, GNU Operators, Regular Expression Syntax, Top +@node Common Operators @chapter Common Operators You compose regular expressions from operators. In the following @@ -691,7 +482,7 @@ Finally, almost all characters lose any special meaning inside a list * Anchoring Operators:: ^ $ @end menu -@node Match-self Operator, Match-any-character Operator, , Common Operators +@node Match-self Operator @section The Match-self Operator (@var{ordinary character}) This operator matches the character itself. All ordinary characters @@ -700,7 +491,7 @@ example, @samp{f} is always an ordinary character, so the regular expression @samp{f} matches only the string @samp{f}. In particular, it does @emph{not} match the string @samp{ff}. -@node Match-any-character Operator, Concatenation Operator, Match-self Operator, Common Operators +@node Match-any-character Operator @section The Match-any-character Operator (@code{.}) @cindex @samp{.} @@ -721,7 +512,7 @@ The @samp{.} (period) character represents this operator. For example, @samp{a.b} matches any three-character string beginning with @samp{a} and ending with @samp{b}. -@node Concatenation Operator, Repetition Operators, Match-any-character Operator, Common Operators +@node Concatenation Operator @section The Concatenation Operator This operator concatenates two regular expressions @var{a} and @var{b}. @@ -730,7 +521,7 @@ No character represents this operator; you simply put @var{b} after @var{a} matches its first part and @var{b} matches the rest. For example, @samp{xy} (two match-self operators) matches @samp{xy}. -@node Repetition Operators, Alternation Operator, Concatenation Operator, Common Operators +@node Repetition Operators @section Repetition Operators Repetition operators repeat the preceding regular expression a specified @@ -743,7 +534,7 @@ number of times. * Interval Operators:: @{@} @end menu -@node Match-zero-or-more Operator, Match-one-or-more Operator, , Repetition Operators +@node Match-zero-or-more Operator @subsection The Match-zero-or-more Operator (@code{*}) @cindex @samp{*} @@ -804,7 +595,7 @@ the string. So it backtracks, discarding the match of the last @samp{a} in the string. It can then match the remaining @samp{ar}. -@node Match-one-or-more Operator, Match-zero-or-one Operator, Match-zero-or-more Operator, Repetition Operators +@node Match-one-or-more Operator @subsection The Match-one-or-more Operator (@code{+} or @code{\+}) @cindex @samp{+} @@ -823,7 +614,7 @@ For example, supposing that @samp{+} represents the match-one-or-more operator; then @samp{ca+r} matches, e.g., @samp{car} and @samp{caaaar}, but not @samp{cr}. -@node Match-zero-or-one Operator, Interval Operators, Match-one-or-more Operator, Repetition Operators +@node Match-zero-or-one Operator @subsection The Match-zero-or-one Operator (@code{?} or @code{\?}) @cindex @samp{?} @@ -841,7 +632,7 @@ For example, supposing that @samp{?} represents the match-zero-or-one operator; then @samp{ca?r} matches both @samp{car} and @samp{cr}, but nothing else. -@node Interval Operators, , Match-zero-or-one Operator, Repetition Operators +@node Interval Operators @subsection Interval Operators (@code{@{} @dots{} @code{@}} or @code{\@{} @dots{} @code{\@}}) @cindex interval expression @@ -903,7 +694,7 @@ than backslashes, which it ignores---in the would-be interval to be ordinary. -@node Alternation Operator, List Operators, Repetition Operators, Common Operators +@node Alternation Operator @section The Alternation Operator (@code{|} or @code{\|}) @kindex | @@ -969,7 +760,7 @@ then it would be content to match just @samp{fooqbar}. @comment xx something about leftmost-longest -@node List Operators, Grouping Operators, Alternation Operator, Common Operators +@node List Operators @section List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) @cindex matching list @@ -1112,7 +903,7 @@ symbol. @end ignore -@node Character Class Operators, Range Operator, , List Operators +@node Character Class Operators @subsection Character Class Operators (@code{[:} @dots{} @code{:]}) @cindex character classes @@ -1177,7 +968,7 @@ only inside of lists; so @samp{[[:alpha:]]} matches any letter, but @samp{[:alpha:]} outside of a bracket expression and not followed by a repetition operator matches just itself. -@node Range Operator, , Character Class Operators, List Operators +@node Range Operator @subsection The Range Operator (@code{-}) Regex recognizes @dfn{range expressions} inside a list. They represent @@ -1237,7 +1028,7 @@ For example, @samp{[-a-z]} matches a lowercase letter or a hyphen (in English, in @sc{ascii}). -@node Grouping Operators, Back-reference Operator, List Operators, Common Operators +@node Grouping Operators @section Grouping Operators (@code{(} @dots{} @code{)} or @code{\(} @dots{} @code{\)}) @kindex ( @@ -1287,7 +1078,7 @@ close-group operator has no matching open-group operator, then Regex considers it to match @samp{)}. -@node Back-reference Operator, Anchoring Operators, Grouping Operators, Common Operators +@node Back-reference Operator @section The Back-reference Operator (@dfn{\}@var{digit}) @cindex back references @@ -1351,7 +1142,7 @@ If there is no preceding @w{@var{digit}-th} subexpression, the regular expression is invalid. -@node Anchoring Operators, , Back-reference Operator, Common Operators +@node Anchoring Operators @section Anchoring Operators @cindex anchoring @@ -1366,7 +1157,7 @@ end of the entire string or at the beginning or end of a line. @end menu -@node Match-beginning-of-line Operator, Match-end-of-line Operator, , Anchoring Operators +@node Match-beginning-of-line Operator @subsection The Match-beginning-of-line Operator (@code{^}) @kindex ^ @@ -1414,7 +1205,7 @@ If the @code{newline_anchor} field is set in the pattern buffer, then regard the string to be matched as broken into lines. -@node Match-end-of-line Operator, , Match-beginning-of-line Operator, Anchoring Operators +@node Match-end-of-line Operator @subsection The Match-end-of-line Operator (@code{$}) @kindex $ @@ -1435,7 +1226,7 @@ exactly the dual of @samp{^}'s; see the previous section. (That is, ``after'' becomes ``before''.) -@node GNU Operators, GNU Emacs Operators, Common Operators, Top +@node GNU Operators @chapter GNU Operators Following are operators that @sc{gnu} defines (and @sc{posix} doesn't). @@ -1445,7 +1236,7 @@ Following are operators that @sc{gnu} defines (and @sc{posix} doesn't). * Buffer Operators:: @end menu -@node Word Operators, Buffer Operators, , GNU Operators +@node Word Operators @section Word Operators The operators in this section require Regex to recognize parts of words. @@ -1462,7 +1253,7 @@ part of a word, i.e., whether or not it is @dfn{word-constituent}. * Match-non-word-constituent Operator:: \W @end menu -@node Non-Emacs Syntax Tables, Match-word-boundary Operator, , Word Operators +@node Non-Emacs Syntax Tables @subsection Non-Emacs Syntax Tables A @dfn{syntax table} is an array indexed by the characters in your @@ -1490,7 +1281,7 @@ the preprocessor symbol @code{emacs} defined. @end itemize -@node Match-word-boundary Operator, Match-within-word Operator, Non-Emacs Syntax Tables, Word Operators +@node Match-word-boundary Operator @subsection The Match-word-boundary Operator (@code{\b}) @cindex @samp{\b} @@ -1500,7 +1291,7 @@ This operator (represented by @samp{\b}) matches the empty string at either the beginning or the end of a word. For example, @samp{\brat\b} matches the separate word @samp{rat}. -@node Match-within-word Operator, Match-beginning-of-word Operator, Match-word-boundary Operator, Word Operators +@node Match-within-word Operator @subsection The Match-within-word Operator (@code{\B}) @cindex @samp{\B} @@ -1509,7 +1300,7 @@ This operator (represented by @samp{\B}) matches the empty string within a word. For example, @samp{c\Brat\Be} matches @samp{crate}, but @samp{dirty \Brat} doesn't match @samp{dirty rat}. -@node Match-beginning-of-word Operator, Match-end-of-word Operator, Match-within-word Operator, Word Operators +@node Match-beginning-of-word Operator @subsection The Match-beginning-of-word Operator (@code{\<}) @cindex @samp{\<} @@ -1517,7 +1308,7 @@ a word. For example, @samp{c\Brat\Be} matches @samp{crate}, but This operator (represented by @samp{\<}) matches the empty string at the beginning of a word. -@node Match-end-of-word Operator, Match-word-constituent Operator, Match-beginning-of-word Operator, Word Operators +@node Match-end-of-word Operator @subsection The Match-end-of-word Operator (@code{\>}) @cindex @samp{\>} @@ -1525,7 +1316,7 @@ beginning of a word. This operator (represented by @samp{\>}) matches the empty string at the end of a word. -@node Match-word-constituent Operator, Match-non-word-constituent Operator, Match-end-of-word Operator, Word Operators +@node Match-word-constituent Operator @subsection The Match-word-constituent Operator (@code{\w}) @cindex @samp{\w} @@ -1533,7 +1324,7 @@ end of a word. This operator (represented by @samp{\w}) matches any word-constituent character. -@node Match-non-word-constituent Operator, , Match-word-constituent Operator, Word Operators +@node Match-non-word-constituent Operator @subsection The Match-non-word-constituent Operator (@code{\W}) @cindex @samp{\W} @@ -1542,7 +1333,7 @@ This operator (represented by @samp{\W}) matches any character that is not word-constituent. -@node Buffer Operators, , Word Operators, GNU Operators +@node Buffer Operators @section Buffer Operators Following are operators which work on buffers. In Emacs, a @dfn{buffer} @@ -1555,7 +1346,7 @@ entire string to be matched as the buffer. @end menu -@node Match-beginning-of-buffer Operator, Match-end-of-buffer Operator, , Buffer Operators +@node Match-beginning-of-buffer Operator @subsection The Match-beginning-of-buffer Operator (@code{\`}) @cindex @samp{\`} @@ -1563,7 +1354,7 @@ entire string to be matched as the buffer. This operator (represented by @samp{\`}) matches the empty string at the beginning of the buffer. -@node Match-end-of-buffer Operator, , Match-beginning-of-buffer Operator, Buffer Operators +@node Match-end-of-buffer Operator @subsection The Match-end-of-buffer Operator (@code{\'}) @cindex @samp{\'} @@ -1572,7 +1363,7 @@ This operator (represented by @samp{\'}) matches the empty string at the end of the buffer. -@node GNU Emacs Operators, What Gets Matched?, GNU Operators, Top +@node GNU Emacs Operators @chapter GNU Emacs Operators Following are operators that @sc{gnu} defines (and @sc{posix} doesn't) @@ -1584,7 +1375,7 @@ symbol @code{emacs} defined. @end menu -@node Syntactic Class Operators, , , GNU Emacs Operators +@node Syntactic Class Operators @section Syntactic Class Operators The operators in this section require Regex to recognize the syntactic @@ -1596,7 +1387,7 @@ classes of characters. Regex uses a syntax table to determine this. * Match-not-syntactic-class Operator:: \SCLASS @end menu -@node Emacs Syntax Tables, Match-syntactic-class Operator, , Syntactic Class Operators +@node Emacs Syntax Tables @subsection Emacs Syntax Tables A @dfn{syntax table} is an array indexed by the characters in your @@ -1610,7 +1401,7 @@ tables are more complicated than Regex's own (@pxref{Non-Emacs Syntax Tables}). @xref{Syntax, , Syntax, emacs, The GNU Emacs User's Manual}, for a description of Emacs' syntax tables. -@node Match-syntactic-class Operator, Match-not-syntactic-class Operator, Emacs Syntax Tables, Syntactic Class Operators +@node Match-syntactic-class Operator @subsection The Match-syntactic-class Operator (@code{\s}@var{class}) @cindex @samp{\s} @@ -1622,7 +1413,7 @@ want. For example, @samp{w} represents the syntactic class of word-constituent characters, so @samp{\sw} matches any word-constituent character. -@node Match-not-syntactic-class Operator, , Match-syntactic-class Operator, Syntactic Class Operators +@node Match-not-syntactic-class Operator @subsection The Match-not-syntactic-class Operator (@code{\S}@var{class}) @cindex @samp{\S} @@ -1635,7 +1426,7 @@ word-constituent characters, so @samp{\Sw} matches any character that is not word-constituent. -@node What Gets Matched?, Programming with Regex, GNU Emacs Operators, Top +@node What Gets Matched? @chapter What Gets Matched? Regex usually matches strings according to the ``leftmost longest'' @@ -1649,7 +1440,7 @@ For example, @samp{(ac*)(c*d[ac]*)\1} matches @samp{acdacaaa}, not first subexpression. -@node Programming with Regex, Copying, What Gets Matched?, Top +@node Programming with Regex @chapter Programming with Regex Here we describe how you use the Regex data structures and functions in @@ -1663,7 +1454,7 @@ compatible with @sc{posix} and one compatible with Berkeley @sc{unix}. @end menu -@node GNU Regex Functions, POSIX Regex Functions, , Programming with Regex +@node GNU Regex Functions @section GNU Regex Functions If you're writing code that doesn't need to be compatible with either @@ -1683,7 +1474,7 @@ provide more options than the other interfaces. @end menu -@node GNU Pattern Buffers, GNU Regular Expression Compiling, , GNU Regex Functions +@node GNU Pattern Buffers @subsection GNU Pattern Buffers @cindex pattern buffer, definition of @@ -1766,7 +1557,7 @@ holding a compiled pattern for a different regular expression. @end example -@node GNU Regular Expression Compiling, GNU Matching, GNU Pattern Buffers, GNU Regex Functions +@node GNU Regular Expression Compiling @subsection GNU Regular Expression Compiling In @sc{gnu}, you can both match and search for a given regular @@ -1870,7 +1661,7 @@ error string corresponding to one of the errors listed in @ref{POSIX Regular Expression Compiling}. -@node GNU Matching, GNU Searching, GNU Regular Expression Compiling, GNU Regex Functions +@node GNU Matching @subsection GNU Matching @cindex matching with GNU functions @@ -1920,7 +1711,7 @@ If @var{start} is not between zero and @var{size}, then @code{re_match} returns @math{-1}. -@node GNU Searching, Matching/Searching with Split Data, GNU Matching, GNU Regex Functions +@node GNU Searching @subsection GNU Searching @cindex searching with GNU functions @@ -1974,7 +1765,7 @@ a match is found, it returns the index where the match began. If an internal error happens, it returns @math{-2}. -@node Matching/Searching with Split Data, Searching with Fastmaps, GNU Searching, GNU Regex Functions +@node Matching/Searching with Split Data @subsection Matching and Searching with Split Data Using the functions @code{re_match_2} and @code{re_search_2}, you can @@ -2020,7 +1811,7 @@ re_search_2 (struct re_pattern_buffer *@var{buffer}, is similarly related to @code{re_search}. -@node Searching with Fastmaps, GNU Translate Tables, Matching/Searching with Split Data, GNU Regex Functions +@node Searching with Fastmaps @subsection Searching with Fastmaps @cindex fastmaps @@ -2077,7 +1868,7 @@ want a fastmap. @code{re_search} will still either do nothing if @code{fastmap} is null or, if it isn't, compile a new fastmap for the new pattern. -@node GNU Translate Tables, Using Registers, Searching with Fastmaps, GNU Regex Functions +@node GNU Translate Tables @subsection GNU Translate Tables If you set the @code{translate} field of a pattern buffer to a translate @@ -2116,7 +1907,7 @@ this field. You'll get weird results if you change the table's contents anytime between compiling the pattern buffer, compiling its fastmap, and matching or searching with the pattern buffer. -@node Using Registers, Freeing GNU Pattern Buffers, GNU Translate Tables, GNU Regex Functions +@node Using Registers @subsection Using Registers A group in a regular expression can match a (posssibly empty) substring @@ -2353,7 +2144,7 @@ string @samp{c}, you get: @end itemize -@node Freeing GNU Pattern Buffers, , Using Registers, GNU Regex Functions +@node Freeing GNU Pattern Buffers @subsection Freeing GNU Pattern Buffers To free any allocated fields of a pattern buffer, you can use the @@ -2365,7 +2156,7 @@ in it (@pxref{GNU Regular Expression Compiling}) before passing it to a matching or searching function. -@node POSIX Regex Functions, BSD Regex Functions, GNU Regex Functions, Programming with Regex +@node POSIX Regex Functions @section POSIX Regex Functions If you're writing code that has to be @sc{posix} compatible, you'll need @@ -2382,7 +2173,7 @@ draft 1003.2/D11.2. @end menu -@node POSIX Pattern Buffers, POSIX Regular Expression Compiling, , POSIX Regex Functions +@node POSIX Pattern Buffers @subsection POSIX Pattern Buffers To compile or match a given regular expression the @sc{posix} way, you @@ -2392,7 +2183,7 @@ must supply a pattern buffer exactly the way you do for @sc{gnu} type @code{re_pattern_buffer}. -@node POSIX Regular Expression Compiling, POSIX Matching, POSIX Pattern Buffers, POSIX Regex Functions +@node POSIX Regular Expression Compiling @subsection POSIX Regular Expression Compiling With @sc{posix}, you can only search for a given regular expression; you @@ -2542,7 +2333,7 @@ Returned when a regular expression makes Regex to run out of memory. @end table -@node POSIX Matching, Reporting Errors, POSIX Regular Expression Compiling, POSIX Regex Functions +@node POSIX Matching @subsection POSIX Matching Matching the @sc{posix} way means trying to match a null-terminated @@ -2586,7 +2377,7 @@ according to the syntax in @var{preg}'s @code{syntax} field. function returns zero if the compiled pattern matches @var{string} and @code{REG_NOMATCH} (defined in @file{regex.h}) if it doesn't. -@node Reporting Errors, Using Byte Offsets, POSIX Matching, POSIX Regex Functions +@node Reporting Errors @subsection Reporting Errors If either @code{regcomp} or @code{regexec} fail, they return a nonzero @@ -2621,7 +2412,7 @@ You can call @code{regerror} with a null @var{errbuf} and a zero @var{errbuf_size} to determine how large @var{errbuf} need be to accommodate @code{regerror}'s error string. -@node Using Byte Offsets, Freeing POSIX Pattern Buffers, Reporting Errors, POSIX Regex Functions +@node Using Byte Offsets @subsection Using Byte Offsets In @sc{posix}, variables of type @code{regmatch_t} hold analogous @@ -2647,7 +2438,7 @@ stores the information into the registers, substitute @var{pmatch} for @code{@w{@var{pmatch}[@var{i}]->}rm_eo} for @code{@w{@var{regs}->}end[@var{i}]}. -@node Freeing POSIX Pattern Buffers, , Using Byte Offsets, POSIX Regex Functions +@node Freeing POSIX Pattern Buffers @subsection Freeing POSIX Pattern Buffers To free any allocated fields of a pattern buffer, use: @@ -2667,7 +2458,7 @@ Compiling}) before passing it to the matching function (@pxref{POSIX Matching}). -@node BSD Regex Functions, , POSIX Regex Functions, Programming with Regex +@node BSD Regex Functions @section BSD Regex Functions If you're writing code that has to be Berkeley @sc{unix} compatible, @@ -2679,7 +2470,7 @@ in Berkeley @sc{unix}. * BSD Searching:: re_exec () @end menu -@node BSD Regular Expression Compiling, BSD Searching, , BSD Regex Functions +@node BSD Regular Expression Compiling @subsection BSD Regular Expression Compiling With Berkeley @sc{unix}, you can only search for a given regular @@ -2713,7 +2504,7 @@ an error string. @code{re_comp}'s error messages are identical to those of @code{re_compile_pattern} (@pxref{GNU Regular Expression Compiling}). -@node BSD Searching, , BSD Regular Expression Compiling, BSD Regex Functions +@node BSD Searching @subsection BSD Searching Searching the Berkeley @sc{unix} way means searching in a string @@ -2734,405 +2525,3 @@ want to search. @code{re_exec} returns either 1 for success or 0 for failure. It automatically uses a @sc{gnu} fastmap (@pxref{Searching with Fastmaps}). - - -@node Copying, Index, Programming with Regex, Top -@appendix GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. -675 Mass Ave, Cambridge, MA 02139, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display - -@unnumberedsec Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The ``Program'', below, -refers to any such program or work, and a ``work based on the Program'' -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term ``modification''.) Each licensee is addressed as ``you''. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - -@item -You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - -@item -You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. - -@item -If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) -@end enumerate - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -@item -You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - -@enumerate a -@item -Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, - -@item -Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, - -@item -Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) -@end enumerate - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - -@item -You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - -@item -You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -@item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - -@item -If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -@item -If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -@item -The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -@item -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. -@end enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the ``copyright'' line and a pointer to where the full notice is found. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -@end smallexample - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. -This is free software, and you are welcome to redistribute it -under certain conditions; type `show c' for details. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{show c}; they could even be mouse-clicks or menu items---whatever -suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: - -@example -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end example - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - - -@node Index, , Copying, Top -@unnumbered Index - -@printindex cp - -@contents - -@bye -- 2.11.0