1 | // This file is part of SmallBASIC |
2 | // |
3 | // The regular expressions routines is based on match.c by J. Kercheval: |
4 | // |
5 | // This program is distributed under the terms of the GPL v2.0 or later |
6 | // Download the GNU Public License (GPL) from www.gnu.org |
7 | // |
8 | // Copyright(C) 2000 Nicholas Christopoulos |
9 | |
10 | /** |
11 | * @file match.h |
12 | @author J. Kercheval |
13 | @date Sat, 01/05/1991 22:21:49 |
14 | |
15 | J. Kercheval Wed, 02/20/1991 22:29:01 Released to Public Domain |
16 | J. Kercheval Fri, 02/22/1991 15:29:01 fix '\' bugs (two :( of them) |
17 | J. Kercheval Sun, 03/10/1991 19:31:29 add error return to RegMatche() |
18 | J. Kercheval Sun, 03/10/1991 20:11:11 add IsValidRegPattern code |
19 | J. Kercheval Sun, 03/10/1991 20:37:11 beef up main() |
20 | J. Kercheval Tue, 03/12/1991 22:25:10 Released as V1.1 to Public Domain |
21 | |
22 | The file match.c coexists in the same directory with the string class. |
23 | */ |
24 | |
25 | #if !defined(_JKMATCH_H) |
26 | #define _JKMATCH_H |
27 | |
28 | #include "common/sys.h" |
29 | |
30 | /* return codes */ |
31 | #define reg_match_literal_failure -1 // reg_match failure on literal |
32 | // (not found) |
33 | #define reg_match_bad_pattern -2 // bad pattern |
34 | #define reg_match_range_failure -3 // reg_match failure on [..] |
35 | // construct |
36 | #define reg_match_abort -4 // premature end of |
37 | // text string |
38 | #define reg_match_premature_end -5 // premature end of pattern |
39 | // string |
40 | #define reg_match_valid 0 // valid reg_match |
41 | /** |
42 | * @ingroup str |
43 | * |
44 | * The regular expressions routines, by J. Kercheval |
45 | * |
46 | @code |
47 | In the pattern string: |
48 | `*' RegMatches any sequence of characters (zero or more) |
49 | `?' RegMatches any character |
50 | [SET] RegMatches any character in the specified set, |
51 | [!SET] or [^SET] RegMatches any character not in the specified set. |
52 | |
53 | A set is composed of characters or ranges; a range looks like |
54 | character hyphen character (as in 0-9 or A-Z). [0-9a-zA-Z_] is the |
55 | minimal set of characters allowed in the [..] pattern construct. |
56 | Other characters are allowed (ie. 8 bit characters) if your system |
57 | will support them. |
58 | |
59 | To suppress the special syntactic significance of any of `[]*?!^-\', |
60 | and RegMatch the character exactly, precede it with a `\'. |
61 | @endcode |
62 | * |
63 | * @param p is the pattern |
64 | * @param t is the text |
65 | * @return 0 on success |
66 | */ |
67 | int reg_match(const char *p, char *t); |
68 | |
69 | #endif |
70 | |