os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/regex.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/regex.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,341 @@
1.4 +#ifndef _REGEX_H_
1.5 +#define _REGEX_H_ /* never again */
1.6 +/*
1.7 + * regular expressions
1.8 + *
1.9 + * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved.
1.10 + *
1.11 + * Development of this software was funded, in part, by Cray Research Inc.,
1.12 + * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
1.13 + * Corporation, none of whom are responsible for the results. The author
1.14 + * thanks all of them.
1.15 + *
1.16 + * Redistribution and use in source and binary forms -- with or without
1.17 + * modification -- are permitted for any purpose, provided that
1.18 + * redistributions in source form retain this entire copyright notice and
1.19 + * indicate the origin and nature of any modifications.
1.20 + *
1.21 + * I'd appreciate being given credit for this package in the documentation
1.22 + * of software which uses it, but that is not a requirement.
1.23 + *
1.24 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
1.25 + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
1.26 + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
1.27 + * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1.28 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1.29 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
1.30 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1.31 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
1.32 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
1.33 + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.34 + *
1.35 + *
1.36 + *
1.37 + * Prototypes etc. marked with "^" within comments get gathered up (and
1.38 + * possibly edited) by the regfwd program and inserted near the bottom of
1.39 + * this file.
1.40 + *
1.41 + * We offer the option of declaring one wide-character version of the
1.42 + * RE functions as well as the char versions. To do that, define
1.43 + * __REG_WIDE_T to the type of wide characters (unfortunately, there
1.44 + * is no consensus that wchar_t is suitable) and __REG_WIDE_COMPILE and
1.45 + * __REG_WIDE_EXEC to the names to be used for the compile and execute
1.46 + * functions (suggestion: re_Xcomp and re_Xexec, where X is a letter
1.47 + * suggestive of the wide type, e.g. re_ucomp and re_uexec for Unicode).
1.48 + * For cranky old compilers, it may be necessary to do something like:
1.49 + * #define __REG_WIDE_COMPILE(a,b,c,d) re_Xcomp(a,b,c,d)
1.50 + * #define __REG_WIDE_EXEC(a,b,c,d,e,f,g) re_Xexec(a,b,c,d,e,f,g)
1.51 + * rather than just #defining the names as parameterless macros.
1.52 + *
1.53 + * For some specialized purposes, it may be desirable to suppress the
1.54 + * declarations of the "front end" functions, regcomp() and regexec(),
1.55 + * or of the char versions of the compile and execute functions. To
1.56 + * suppress the front-end functions, define __REG_NOFRONT. To suppress
1.57 + * the char versions, define __REG_NOCHAR.
1.58 + *
1.59 + * The right place to do those defines (and some others you may want, see
1.60 + * below) would be <sys/types.h>. If you don't have control of that file,
1.61 + * the right place to add your own defines to this file is marked below.
1.62 + * This is normally done automatically, by the makefile and regmkhdr, based
1.63 + * on the contents of regcustom.h.
1.64 + */
1.65 +
1.66 +
1.67 +
1.68 +/*
1.69 + * voodoo for C++
1.70 + */
1.71 +#ifdef __cplusplus
1.72 +extern "C" {
1.73 +#endif
1.74 +
1.75 +
1.76 +
1.77 +/*
1.78 + * Add your own defines, if needed, here.
1.79 + */
1.80 +
1.81 +
1.82 +
1.83 +/*
1.84 + * Location where a chunk of regcustom.h is automatically spliced into
1.85 + * this file (working from its prototype, regproto.h).
1.86 + */
1.87 +/* --- begin --- */
1.88 +/* ensure certain things don't sneak in from system headers */
1.89 +#ifdef __REG_WIDE_T
1.90 +#undef __REG_WIDE_T
1.91 +#endif
1.92 +#ifdef __REG_WIDE_COMPILE
1.93 +#undef __REG_WIDE_COMPILE
1.94 +#endif
1.95 +#ifdef __REG_WIDE_EXEC
1.96 +#undef __REG_WIDE_EXEC
1.97 +#endif
1.98 +#ifdef __REG_REGOFF_T
1.99 +#undef __REG_REGOFF_T
1.100 +#endif
1.101 +#ifdef __REG_VOID_T
1.102 +#undef __REG_VOID_T
1.103 +#endif
1.104 +#ifdef __REG_CONST
1.105 +#undef __REG_CONST
1.106 +#endif
1.107 +#ifdef __REG_NOFRONT
1.108 +#undef __REG_NOFRONT
1.109 +#endif
1.110 +#ifdef __REG_NOCHAR
1.111 +#undef __REG_NOCHAR
1.112 +#endif
1.113 +/* interface types */
1.114 +#define __REG_WIDE_T Tcl_UniChar
1.115 +#define __REG_REGOFF_T long /* not really right, but good enough... */
1.116 +#define __REG_VOID_T VOID
1.117 +#define __REG_CONST CONST
1.118 +/* names and declarations */
1.119 +#define __REG_WIDE_COMPILE TclReComp
1.120 +#define __REG_WIDE_EXEC TclReExec
1.121 +#define __REG_NOFRONT /* don't want regcomp() and regexec() */
1.122 +#define __REG_NOCHAR /* or the char versions */
1.123 +#define regfree TclReFree
1.124 +#define regerror TclReError
1.125 +/* --- end --- */
1.126 +
1.127 +
1.128 +/*
1.129 + * interface types etc.
1.130 + */
1.131 +
1.132 +/*
1.133 + * regoff_t has to be large enough to hold either off_t or ssize_t,
1.134 + * and must be signed; it's only a guess that long is suitable, so we
1.135 + * offer <sys/types.h> an override.
1.136 + */
1.137 +#ifdef __REG_REGOFF_T
1.138 +typedef __REG_REGOFF_T regoff_t;
1.139 +#else
1.140 +typedef long regoff_t;
1.141 +#endif
1.142 +
1.143 +/*
1.144 + * For benefit of old compilers, we offer <sys/types.h> the option of
1.145 + * overriding the `void' type used to declare nonexistent return types.
1.146 + */
1.147 +#ifdef __REG_VOID_T
1.148 +typedef __REG_VOID_T re_void;
1.149 +#else
1.150 +typedef void re_void;
1.151 +#endif
1.152 +
1.153 +/*
1.154 + * Also for benefit of old compilers, <sys/types.h> can supply a macro
1.155 + * which expands to a substitute for `const'.
1.156 + */
1.157 +#ifndef __REG_CONST
1.158 +#define __REG_CONST const
1.159 +#endif
1.160 +
1.161 +
1.162 +
1.163 +/*
1.164 + * other interface types
1.165 + */
1.166 +
1.167 +/* the biggie, a compiled RE (or rather, a front end to same) */
1.168 +typedef struct {
1.169 + int re_magic; /* magic number */
1.170 + size_t re_nsub; /* number of subexpressions */
1.171 + long re_info; /* information about RE */
1.172 +# define REG_UBACKREF 000001
1.173 +# define REG_ULOOKAHEAD 000002
1.174 +# define REG_UBOUNDS 000004
1.175 +# define REG_UBRACES 000010
1.176 +# define REG_UBSALNUM 000020
1.177 +# define REG_UPBOTCH 000040
1.178 +# define REG_UBBS 000100
1.179 +# define REG_UNONPOSIX 000200
1.180 +# define REG_UUNSPEC 000400
1.181 +# define REG_UUNPORT 001000
1.182 +# define REG_ULOCALE 002000
1.183 +# define REG_UEMPTYMATCH 004000
1.184 +# define REG_UIMPOSSIBLE 010000
1.185 +# define REG_USHORTEST 020000
1.186 + int re_csize; /* sizeof(character) */
1.187 + char *re_endp; /* backward compatibility kludge */
1.188 + /* the rest is opaque pointers to hidden innards */
1.189 + char *re_guts; /* `char *' is more portable than `void *' */
1.190 + char *re_fns;
1.191 +} regex_t;
1.192 +
1.193 +/* result reporting (may acquire more fields later) */
1.194 +typedef struct {
1.195 + regoff_t rm_so; /* start of substring */
1.196 + regoff_t rm_eo; /* end of substring */
1.197 +} regmatch_t;
1.198 +
1.199 +/* supplementary control and reporting */
1.200 +typedef struct {
1.201 + regmatch_t rm_extend; /* see REG_EXPECT */
1.202 +} rm_detail_t;
1.203 +
1.204 +
1.205 +
1.206 +/*
1.207 + * compilation
1.208 + ^ #ifndef __REG_NOCHAR
1.209 + ^ int re_comp(regex_t *, __REG_CONST char *, size_t, int);
1.210 + ^ #endif
1.211 + ^ #ifndef __REG_NOFRONT
1.212 + ^ int regcomp(regex_t *, __REG_CONST char *, int);
1.213 + ^ #endif
1.214 + ^ #ifdef __REG_WIDE_T
1.215 + ^ int __REG_WIDE_COMPILE(regex_t *, __REG_CONST __REG_WIDE_T *, size_t, int);
1.216 + ^ #endif
1.217 + */
1.218 +#define REG_BASIC 000000 /* BREs (convenience) */
1.219 +#define REG_EXTENDED 000001 /* EREs */
1.220 +#define REG_ADVF 000002 /* advanced features in EREs */
1.221 +#define REG_ADVANCED 000003 /* AREs (which are also EREs) */
1.222 +#define REG_QUOTE 000004 /* no special characters, none */
1.223 +#define REG_NOSPEC REG_QUOTE /* historical synonym */
1.224 +#define REG_ICASE 000010 /* ignore case */
1.225 +#define REG_NOSUB 000020 /* don't care about subexpressions */
1.226 +#define REG_EXPANDED 000040 /* expanded format, white space & comments */
1.227 +#define REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */
1.228 +#define REG_NLANCH 000200 /* ^ matches after \n, $ before */
1.229 +#define REG_NEWLINE 000300 /* newlines are line terminators */
1.230 +#define REG_PEND 000400 /* ugh -- backward-compatibility hack */
1.231 +#define REG_EXPECT 001000 /* report details on partial/limited matches */
1.232 +#define REG_BOSONLY 002000 /* temporary kludge for BOS-only matches */
1.233 +#define REG_DUMP 004000 /* none of your business :-) */
1.234 +#define REG_FAKE 010000 /* none of your business :-) */
1.235 +#define REG_PROGRESS 020000 /* none of your business :-) */
1.236 +
1.237 +
1.238 +
1.239 +/*
1.240 + * execution
1.241 + ^ #ifndef __REG_NOCHAR
1.242 + ^ int re_exec(regex_t *, __REG_CONST char *, size_t,
1.243 + ^ rm_detail_t *, size_t, regmatch_t [], int);
1.244 + ^ #endif
1.245 + ^ #ifndef __REG_NOFRONT
1.246 + ^ int regexec(regex_t *, __REG_CONST char *, size_t, regmatch_t [], int);
1.247 + ^ #endif
1.248 + ^ #ifdef __REG_WIDE_T
1.249 + ^ int __REG_WIDE_EXEC(regex_t *, __REG_CONST __REG_WIDE_T *, size_t,
1.250 + ^ rm_detail_t *, size_t, regmatch_t [], int);
1.251 + ^ #endif
1.252 + */
1.253 +#define REG_NOTBOL 0001 /* BOS is not BOL */
1.254 +#define REG_NOTEOL 0002 /* EOS is not EOL */
1.255 +#define REG_STARTEND 0004 /* backward compatibility kludge */
1.256 +#define REG_FTRACE 0010 /* none of your business */
1.257 +#define REG_MTRACE 0020 /* none of your business */
1.258 +#define REG_SMALL 0040 /* none of your business */
1.259 +
1.260 +
1.261 +
1.262 +/*
1.263 + * misc generics (may be more functions here eventually)
1.264 + ^ re_void regfree(regex_t *);
1.265 + */
1.266 +
1.267 +
1.268 +
1.269 +/*
1.270 + * error reporting
1.271 + * Be careful if modifying the list of error codes -- the table used by
1.272 + * regerror() is generated automatically from this file!
1.273 + *
1.274 + * Note that there is no wide-char variant of regerror at this time; what
1.275 + * kind of character is used for error reports is independent of what kind
1.276 + * is used in matching.
1.277 + *
1.278 + ^ extern size_t regerror(int, __REG_CONST regex_t *, char *, size_t);
1.279 + */
1.280 +#define REG_OKAY 0 /* no errors detected */
1.281 +#define REG_NOMATCH 1 /* failed to match */
1.282 +#define REG_BADPAT 2 /* invalid regexp */
1.283 +#define REG_ECOLLATE 3 /* invalid collating element */
1.284 +#define REG_ECTYPE 4 /* invalid character class */
1.285 +#define REG_EESCAPE 5 /* invalid escape \ sequence */
1.286 +#define REG_ESUBREG 6 /* invalid backreference number */
1.287 +#define REG_EBRACK 7 /* brackets [] not balanced */
1.288 +#define REG_EPAREN 8 /* parentheses () not balanced */
1.289 +#define REG_EBRACE 9 /* braces {} not balanced */
1.290 +#define REG_BADBR 10 /* invalid repetition count(s) */
1.291 +#define REG_ERANGE 11 /* invalid character range */
1.292 +#define REG_ESPACE 12 /* out of memory */
1.293 +#define REG_BADRPT 13 /* quantifier operand invalid */
1.294 +#define REG_ASSERT 15 /* "can't happen" -- you found a bug */
1.295 +#define REG_INVARG 16 /* invalid argument to regex function */
1.296 +#define REG_MIXED 17 /* character widths of regex and string differ */
1.297 +#define REG_BADOPT 18 /* invalid embedded option */
1.298 +/* two specials for debugging and testing */
1.299 +#define REG_ATOI 101 /* convert error-code name to number */
1.300 +#define REG_ITOA 102 /* convert error-code number to name */
1.301 +
1.302 +
1.303 +
1.304 +/*
1.305 + * the prototypes, as possibly munched by regfwd
1.306 + */
1.307 +/* =====^!^===== begin forwards =====^!^===== */
1.308 +/* automatically gathered by fwd; do not hand-edit */
1.309 +/* === regproto.h === */
1.310 +#ifndef __REG_NOCHAR
1.311 +int re_comp _ANSI_ARGS_((regex_t *, __REG_CONST char *, size_t, int));
1.312 +#endif
1.313 +#ifndef __REG_NOFRONT
1.314 +int regcomp _ANSI_ARGS_((regex_t *, __REG_CONST char *, int));
1.315 +#endif
1.316 +#ifdef __REG_WIDE_T
1.317 +int __REG_WIDE_COMPILE _ANSI_ARGS_((regex_t *, __REG_CONST __REG_WIDE_T *, size_t, int));
1.318 +#endif
1.319 +#ifndef __REG_NOCHAR
1.320 +int re_exec _ANSI_ARGS_((regex_t *, __REG_CONST char *, size_t, rm_detail_t *, size_t, regmatch_t [], int));
1.321 +#endif
1.322 +#ifndef __REG_NOFRONT
1.323 +int regexec _ANSI_ARGS_((regex_t *, __REG_CONST char *, size_t, regmatch_t [], int));
1.324 +#endif
1.325 +#ifdef __REG_WIDE_T
1.326 +int __REG_WIDE_EXEC _ANSI_ARGS_((regex_t *, __REG_CONST __REG_WIDE_T *, size_t, rm_detail_t *, size_t, regmatch_t [], int));
1.327 +#endif
1.328 +re_void regfree _ANSI_ARGS_((regex_t *));
1.329 +extern size_t regerror _ANSI_ARGS_((int, __REG_CONST regex_t *, char *, size_t));
1.330 +/* automatically gathered by fwd; do not hand-edit */
1.331 +/* =====^!^===== end forwards =====^!^===== */
1.332 +
1.333 +
1.334 +
1.335 +/*
1.336 + * more C++ voodoo
1.337 + */
1.338 +#ifdef __cplusplus
1.339 +}
1.340 +#endif
1.341 +
1.342 +
1.343 +
1.344 +#endif