From bdbd6c954b97e7f16640d8ad3569d601bda8c405 Mon Sep 17 00:00:00 2001 From: rrt Date: Wed, 2 May 2007 16:40:53 +0000 Subject: Remove generated HTML files from CVS, and make Makefile work a bit more widely compatible. --- doc/Makefile | 8 +- doc/index.html | 46 --- doc/manual.html | 1162 ------------------------------------------------------- 3 files changed, 5 insertions(+), 1211 deletions(-) delete mode 100755 doc/index.html delete mode 100755 doc/manual.html (limited to 'doc') diff --git a/doc/Makefile b/doc/Makefile index 2eb2498..090d445 100755 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,5 +1,8 @@ +# Documentation Makefile -APP = C:/Python24/python c:/python24/Scripts/rst2html.py +.SUFFIXES: .txt .html + +APP = rst2html CSS = --stylesheet-path=lrexlib.css --link-stylesheet HDR = --initial-header-level=2 DT = --date --time @@ -8,5 +11,4 @@ DT = --date --time .txt.html: $(APP) $(CSS) $(GT) $(HDR) $(DT) $< $@ -all: manual.html - +all: index.html manual.html diff --git a/doc/index.html b/doc/index.html deleted file mode 100755 index 342e9ec..0000000 --- a/doc/index.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - -Lrexlib 2.2 - - - -
-

Lrexlib 2.2

- -
-
by Reuben Thomas (rrt@sc3d.org)
-
and Shmuel Zeigerman (shmuz@actcom.co.il) [maintainer]
-
-

Lrexlib is a regular expression library for Lua 5.1. The makefiles -provided build it into shared libraries called rex_posix.so and -rex_pcre.so, which can be used with require or loadlib.

-

Lrexlib is copyright Reuben Thomas 2000-2007 and copyright Shmuel -Zeigerman 2004-2007, and is released under the MIT license, like Lua -(see http://www.lua.org/copyright.html for the full license; it's -basically the same as the BSD license). There is no warranty.

-

Please report bugs and make suggestions to the maintainer, or use the -LuaForge trackers and mailing lists.

-

Thanks to Thatcher Ulrich for bug and warning fixes, and to Nick -Gammon for adding support for PCRE named subpatterns.

-
-
-

Links

- -
-
- - - diff --git a/doc/manual.html b/doc/manual.html deleted file mode 100755 index 25a2754..0000000 --- a/doc/manual.html +++ /dev/null @@ -1,1162 +0,0 @@ - - - - - - -Lrexlib 2.2 Reference Manual - - - -
-

Lrexlib 2.2 Reference Manual

- - -
-
-

Introduction

-

Lrexlib provides bindings of the two principal regular expression library -interfaces (POSIX and PCRE) to Lua 5.1.

-

Lrexlib builds into shared libraries called by default rex_posix.so and -rex_pcre.so, which can be used with require.

-

Lrexlib is copyright Reuben Thomas 2000-2007 and copyright Shmuel Zeigerman -2004-2007, and is released under the MIT license.

-
-
-
-

Notes

-
    -
  1. Most functions and methods in Lrexlib have mandatory and optional arguments. -There are no dependencies between arguments in Lrexlib's functions and -methods. Any optional argument can be supplied as nil (or omitted if it -is trailing one), the library will then use the default value for that -argument.

    -
  2. -
  3. This document uses the following syntax for optional arguments: they are -bracketed separately, and commas are left outside brackets, e.g.:

    -
    -MyFunc (arg1, arg2, [arg3], [arg4])
    -
    -
  4. -
  5. Throughout this document, the identifier rex is used in place of either -rex_posix or rex_pcre, that are the default namespaces for the -corresponding libraries.

    -
  6. -
  7. All functions receiving a regular expression pattern as an argument will -generate an error if that pattern is found invalid by the used POSIX / PCRE -library.

    -
  8. -
-
    -
  1. The default value for compilation flags (cf) that Lrexlib uses when -the parameter is not supplied or nil, is:

    -
    -
      -
    • 0 for PCRE
    • -
    • REG_EXTENDED for POSIX regex library
    • -
    -
    -

    For PCRE, cf may also be supplied as a string, whose characters stand for -PCRE compilation flags. Combinations of the following characters (case -sensitive) are supported:

    -
    - ---- - - - - - - - - - - - - - - - - - - - - - - - - - -

    Character

    -

    PCRE flag

    -

    i

    -

    PCRE_CASELESS

    -

    m

    -

    PCRE_MULTILINE

    -

    s

    -

    PCRE_DOTALL

    -

    x

    -

    PCRE_EXTENDED

    -

    U

    -

    PCRE_UNGREEDY

    -

    X

    -

    PCRE_EXTRA

    -
    -
    -
  2. -
-
    -
  1. The default value for execution flags (ef) that Lrexlib uses when -the parameter is not supplied or nil, is:

    -
    -
      -
    • 0 for PCRE
    • -
    • 0 for standard POSIX regex library
    • -
    • REG_STARTEND for those POSIX regex libraries that support it, -e.g. Spencer's.
    • -
    -
    -
  2. -
-
    -
  1. Parameter locale (lo) can be either a string (e.g., "French_France.1252"), -or a userdata obtained from a call to maketables. The default value that -Lrexlib uses when the parameter is not supplied or nil, is:

    -
    -
      -
    • the built-in PCRE set of character tables - when Lrexlib is loaded.
    • -
    • determined by the last call to settables.
    • -
    -
    -
  2. -
-
-
-
-

Common (PCRE and POSIX) functions and methods

-
-

match

-

rex.match (subj, patt, [init], [cf], [ef], [lo])

-

The function searches for the first match of the regexp patt in the string -subj, starting from offset init, subject to flags cf and ef.

-

PCRE: A locale lo may be specified.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
subjsubjectstringn/a
pattregular expression patternstringn/a
[init]start offset in the subject -(can be negative)number1
[cf]compilation flags (bitwise OR)numbercf
[ef]execution flags (bitwise OR)numberef
[lo][PCRE] localestring -or -userdatalocale
-
-
-
Returns on success:
-
    -
  1. All substring matches ("captures"), in the order they appear in the -pattern. false is returned for sub-patterns that did not participate in -the match. If the pattern specified no captures then the whole matched -substring is returned.
  2. -
-
-
Returns on failure:
-
    -
  1. nil
  2. -
-
-
-
-
-
-

find

-

rex.find (subj, patt, [init], [cf], [ef], [lo])

-

The function searches for the first match of the regexp patt in the string -subj, starting from offset init, subject to flags cf and ef.

-

PCRE: A locale lo may be specified.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
subjsubjectstringn/a
pattregular expression patternstringn/a
[init]start offset in the subject -(can be negative)number1
[cf]compilation flags (bitwise OR)numbercf
[ef]execution flags (bitwise OR)numberef
[lo][PCRE] localestring -or -userdatalocale
-
-
-
Returns on success:
-
    -
  1. The start point of the match (a number).
  2. -
  3. The end point of the match (a number).
  4. -
  5. All substring matches ("captures"), in the order they appear in the -pattern. false is returned for sub-patterns that did not participate in -the match.
  6. -
-
-
Returns on failure:
-
    -
  1. nil
  2. -
-
-
-
-
-
-

gmatch

-

rex.gmatch (subj, patt, [cf], [ef], [lo])

-

The function is intended for use in the generic for Lua construct. -It returns an iterator for repeated matching of the pattern patt in -the string subj, subject to flags cf and ef.

-

PCRE: A locale lo may be specified.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
subjsubjectstringn/a
pattregular expression patternstringn/a
[cf]compilation flags (bitwise OR)numbercf
[ef]execution flags (bitwise OR)numberef
[lo][PCRE] localestring -or -userdatalocale
-
-

The iterator function is called by Lua. On every iteration (that is, on every -match), it returns all captures in the order they appear in the pattern (or the -entire match if the pattern specified no captures). The iteration will continue -till the subject fails to match.

-
-
-
-

gsub

-

rex.gsub (subj, patt, repl, [n], [cf], [ef], [lo])

-

This function searches for all matches of the pattern patt in the string -subj and replaces them according to the parameters repl and n (see details -below).

-

PCRE: A locale lo may be specified.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
subjsubjectstringn/a
pattregular expression patternstringn/a
replsubstitution sourcestring, function or tablen/a
[n]maximum number of matches to search -for, or control function, or nilnumber or functionnil
[cf]compilation flags (bitwise OR)numbercf
[ef]execution flags (bitwise OR)numberef
[lo][PCRE] localestring or userdatalocale
-
-
-
Returns:
-
    -
  1. The subject string with the substitutions made.
  2. -
  3. Number of matches found.
  4. -
  5. Number of substitutions made.
  6. -
-
-
Details:
-

The parameter repl can be either a string, a function or a table. -On each match made, it is converted into a value repl_out that may be used -for the replacement.

-

repl_out is generated differently depending on the type of repl:

-
    -
  1. If repl is a string then it is treated as a template for substitution, -where the %X occurences in repl are handled in a special way, depending -on the value of the character X:
  2. -
-
-
    -
  • if X represents a digit, then each %X occurence is substituted by the -value of the X-th submatch (capture), with the following cases handled -specially:
      -
    • each %0 is substituted by the entire match
    • -
    • if the pattern contains no captures, then each %1 is substituted by the -entire match
    • -
    • any other %X where X is greater than the number of captures in the -pattern will generate an error ("invalid capture index")
    • -
    • if the pattern does contain a capture with number X but that capture -didn't participate in the match, then %X is substituted by an empty -string
    • -
    -
  • -
  • if X is any non-digit character then %X is substituted by X
  • -
-

All parts of repl other than %X are copied to repl_out verbatim.

-
-
    -
  1. If repl is a function then it is called on each match with the -submatches passed as parameters (if there are no submatches then the entire -match is passed as the only parameter). repl_out is the return value of -the repl call, and is interpreted as follows:
  2. -
-
-
    -
  • if it is a string or a number (coerced to a string), then the replacement -value is that string;
  • -
  • if it is a nil or a false, then no replacement is to be done;
  • -
-
-
    -
  1. If repl is a table then repl_out is repl [m1], where m1 is the first -submatch (or the entire match if there are no submatches), following the -same rules as for the return value of repl call, described in the above -paragraph.
  2. -
-

Note: Under some circumstances, the value of repl_out may be ignored; see -below.

-

gsub behaves differently depending on the type of n:

-
    -
  1. If n is a number then it is treated as the maximum number of matches -to search for (an omitted or nil value means an unlimited number of -matches). On each match, the replacement value is the repl_out string -(see above).
  2. -
-
-
-
-
    -
  1. If n is a function, then it is called on each match, after repl_out is -produced (so if repl is a function, it will be called prior to the n -call).

    -

    n receives 3 arguments and returns 2 values. Its arguments are:

    -
    -
      -
    1. The start offset of the match (a number)
    2. -
    3. The end offset of the match (a number)
    4. -
    5. repl_out
    6. -
    -
    -

    The type of its first return controls the replacement produced by gsub for -the current match:

    -
    -
      -
    • true -- replace/don't replace, according to repl_out;
    • -
    • nil/false -- don't replace;
    • -
    • a string (or a number coerced to a string) -- replace by that string;
    • -
    -
    -

    The type of its second return controls gsub behavior after the current -match is handled:

    -
    -
      -
    • nil/false -- no changes: n will be called on the next match;
    • -
    • true -- search for an unlimited number of matches; n will not be -called anymore;
    • -
    • a number -- maximum number of matches to search for, beginning from the -next match; n will not be called anymore;
    • -
    -
    -
  2. -
-
-
-
-
-

split

-

rex.split (subj, sep, [cf], [ef], [lo])

-

The function is intended for use in the generic for Lua construct. -It is used for splitting a subject string subj into parts (sections). -The sep parameter is a regular expression pattern representing -separators between the sections.

-

The function returns an iterator for repeated matching of the pattern sep in -the string subj, subject to flags cf and ef.

-

PCRE: A locale lo may be specified.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
subjsubjectstringn/a
sepseparator (regular expression -pattern)stringn/a
[cf]compilation flags (bitwise OR)numbercf
[ef]execution flags (bitwise OR)numberef
[lo][PCRE] localestring -or -userdatalocale
-
-

On every iteration pass, the iterator returns:

-
-
    -
  1. A subject section (can be an empty string), followed by
  2. -
  3. All captures in the order they appear in the sep pattern (or the entire -match if the sep pattern specified no captures). If there is no match -(this can occur only in the last iteration), then nothing is returned after -the subject section.
  4. -
-
-

The iteration will continue till the end of the subject. Unlike gmatch, there -will always be at least one iteration pass, even if there's no matches in the -subject.

-
-
-
-

flags

-

rex.flags ([tb])

-

This function returns a table containing numeric values of the constants defined -by the used regex library (either PCRE or POSIX). Those constants are keyed by -their names (strings). If the table argument tb is supplied then it is used as -the output table, else a new table is created.

-

The constants contained in the returned table can then be used in most functions -and methods where compilation flags or execution flags can be specified. -They can also be used for comparing with return codes of some functions and -methods for determining the reason of failure. For details, see PCRE and POSIX -documentation.

-
- ------ - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
[tb]a table for placing results intotablenil
-
-
-
Returns:
-
    -
  1. A table filled with the results.
  2. -
-
-
-
-
-
-

new

-

rex.new (patt, [cf], [lo])

-

The functions compiles regular expression patt into a regular expression -object whose internal representation is correspondent to the library used (PCRE -or POSIX regex). The returned result then can be used by the methods tfind, -exec and dfa_exec. Regular expression objects are automatically garbage -collected.

-

PCRE: A locale lo may be specified.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
pattregular expression patternstringn/a
[cf]compilation flags (bitwise OR)numbercf
[lo][PCRE] localestring -or -userdatalocale
-
-
-
Returns:
-
    -
  1. Compiled regular expression (a userdata).
  2. -
-
-
-
-
-
-

tfind

-

r:tfind (subj, [init], [ef])

-

The method searches for the first match of the compiled regexp r in the -string subj, starting from offset init, subject to execution flags ef.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
rregex object produced by newuserdatan/a
subjsubjectstringn/a
[init]start offset in the subject -(can be negative)number1
[ef]execution flags (bitwise OR)numberef
-
-
-
Returns on success:
-
    -
  1. The start point of the match (a number).
  2. -
  3. The end point of the match (a number).
  4. -
  5. Substring matches ("captures" in Lua terminology) are returned as a third -result, in a table. This table contains false in the positions where the -corresponding sub-pattern did not participate in the match.
      -
    1. PCRE: if named subpatterns are used then the table also contains -substring matches keyed by their correspondent subpattern names -(strings).
    2. -
    -
  6. -
-
-
Returns on failure:
-
    -
  1. nil
  2. -
-
-
Notes:
-
    -
  1. If named subpatterns (see PCRE docs) are used then the returned table -also contains substring matches keyed by their correspondent subpattern -names (strings).
  2. -
-
-
-
-
-
-

exec

-

r:exec (subj, [init], [ef])

-

The method searches for the first match of the compiled regexp r in the -string subj, starting from offset init, subject to execution flags ef.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
rregex object produced by newuserdatan/a
subjsubjectstringn/a
[init]start offset in the subject -(can be negative)number1
[ef]execution flags (bitwise OR)numberef
-
-
-
Returns on success:
-
    -
  1. The start point of the first match (a number).
  2. -
  3. The end point of the first match (a number).
  4. -
  5. The offsets of substring matches ("captures" in Lua terminology) are -returned as a third result, in a table. This table contains false in the -positions where the corresponding sub-pattern did not participate in the -match.
      -
    1. PCRE: if named subpatterns are used then the table also contains -substring matches keyed by their correspondent subpattern names -(strings).
    2. -
    -
  6. -
-
-
Returns on failure:
-
    -
  1. nil
  2. -
-
-
Example:
-
If the whole match is at offsets 10,20 and substring matches are at offsets -12,14 and 16,19 then the function returns the following: 10, 20, -{ 12,14,16,19 }.
-
-
-
-
-
-

PCRE-only functions and methods

-
-

dfa_exec

-

[PCRE 6.0 and later. See pcre_dfa_exec in the PCRE docs.]

-

r:dfa_exec (subj, [init], [ef], [ovecsize], [wscount])

-

The method matches a compiled regular expression r against a given subject -string subj, using a DFA matching algorithm.

-
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
rregex object produced by newuserdatan/a
subjsubjectstringn/a
[init]start offset in the subject -(can be negative)number1
[ef]execution flags (bitwise OR)numberef
[ovecsize]size of the array for result offsetsnumber100
[wscount]number of elements in the working -space arraynumber50
-
-
-
Returns on success (either full or partial match):
-
    -
  1. The start point of the matches found (a number).
  2. -
  3. A table containing the end points of the matches found, the longer matches -first.
  4. -
  5. The return value of the underlying pcre_dfa_exec call (a number).
  6. -
-
-
Returns on failure (no match):
-
    -
  1. nil
  2. -
-
-
Example:
-
If there are 3 matches found starting at offset 10 and ending at offsets 15, 20 -and 25 then the function returns the following: 10, { 25,20,15 }, 3.
-
-
-
-
-

maketables

-

[PCRE only. See pcre_maketables in the PCRE docs.]

-

rex.maketables ()

-

Creates a table set corresponding to the current active locale and returns it as -a userdata. The returned value can be passed to the function settables and to -any Lrexlib function accepting the locale parameter.

-
-
-
-

settables

-

[PCRE only]

-

rex.settables ([tables])

-

This function replaces the default set of character tables, by the one supplied -in the parameter tables.

-

The tables parameter should be either a userdata, obtained from a call to -maketables, or nil. In the latter case, the built-in PCRE set of tables -becomes the default.

-

Lrexlib maintains one "default" set of character tables, in addition to the set -built-in into PCRE. When a Lrexlib function accepting the locale argument is -called with that argument omitted, then the default set of character tables is -used.

-

The initial default set of tables is the built-in PCRE set.

-
- ------ - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
[tables]See the above description.userdatanil
-
-
-
Returns:
-
The old value of the default set (nil for the built-in PCRE set).
-
-
-
-
-

config

-

[PCRE 4.0 and later. See pcre_config in the PCRE docs.]

-

rex.config ([tb])

-

This function returns a table containing the values of the configuration -parameters used at PCRE library build-time. Those parameters (numbers) are -keyed by their names (strings). If the table argument tb is supplied then it -is used as the output table, else a new table is created.

-
- ------ - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
[tb]a table for placing results intotablenil
-
-
-
Returns:
-
    -
  1. A table filled with the results.
  2. -
-
-
-
-
-
-

version

-

[PCRE only. See pcre_version in the PCRE docs.]

-

rex.version ()

-

This function returns a string containing the version of the used PCRE library -and its release date.

-
-
-
-
-

Other functions

-
-

plainfind

-

rex.plainfind (subj, patt, [init], [ci])

-

The function searches for the first match of the string patt in the subject -subj, starting from offset init.

-
-
    -
  • The string patt is not regular expression, all its characters stand for -themselves.
  • -
  • Both strings subj and patt can have embedded zeros.
  • -
  • The flag ci specifies case-insensitive search (current locale is used).
  • -
  • This function uses neither PCRE nor POSIX regex library.
  • -
- ------ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionTypeDefault Value
subjsubjectstringn/a
patttext to findstringn/a
[init]start offset in the subject -(can be negative)number1
[ci]case insensitive searchbooleanfalse
-
-
-
Returns on success:
-
    -
  1. The start point of the match (a number).
  2. -
  3. The end point of the match (a number).
  4. -
-
-
Returns on failure:
-
    -
  1. nil
  2. -
-
-
-
-
-
-
-

Incompatibilities with the Previous Versions

-

Incompatibilities between the versions 2.0 and 1.19:

-
-
    -
  1. Lua 5.1 is required
  2. -
  3. Functions newPCRE and newPOSIX renamed to new
  4. -
  5. Functions flagsPCRE and flagsPOSIX renamed to flags
  6. -
  7. Function versionPCRE renamed to version
  8. -
  9. Method match renamed to tfind
  10. -
  11. Method gmatch removed (similar functionality is provided by function -gmatch)
  12. -
  13. Methods tfind and exec: 2 values are returned on failure
  14. -
  15. (PCRE) exec: the returned table may additionally contain named -subpatterns
  16. -
-
-

Incompatibilities between the versions 2.1 and 2.0:

-
-
    -
  1. match, find, tfind, exec, dfa_exec: only one value (a nil) is -returned when the subject does not match the pattern. Any other failure -generates an error.
  2. -
-
-

Incompatibilities between the versions 2.2 and 2.1:

-
-
    -
  1. gsub: a special "break" return of repl function is deprecated.
  2. -
  3. (PCRE) gsub, gmatch: after finding an empty match at the current -position, the functions try to find a non-empty match anchored to the same -position.
  4. -
-
-
-
- - - -- cgit v1.2.1