os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/regfronts.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/regfronts.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,83 @@
     1.4 +/*
     1.5 + * regcomp and regexec - front ends to re_ routines
     1.6 + *
     1.7 + * Mostly for implementation of backward-compatibility kludges.  Note
     1.8 + * that these routines exist ONLY in char versions.
     1.9 + *
    1.10 + * Copyright (c) 1998, 1999 Henry Spencer.  All rights reserved.
    1.11 + * 
    1.12 + * Development of this software was funded, in part, by Cray Research Inc.,
    1.13 + * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
    1.14 + * Corporation, none of whom are responsible for the results.  The author
    1.15 + * thanks all of them. 
    1.16 + * 
    1.17 + * Redistribution and use in source and binary forms -- with or without
    1.18 + * modification -- are permitted for any purpose, provided that
    1.19 + * redistributions in source form retain this entire copyright notice and
    1.20 + * indicate the origin and nature of any modifications.
    1.21 + * 
    1.22 + * I'd appreciate being given credit for this package in the documentation
    1.23 + * of software which uses it, but that is not a requirement.
    1.24 + * 
    1.25 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
    1.26 + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    1.27 + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
    1.28 + * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    1.29 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    1.30 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    1.31 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    1.32 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    1.33 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
    1.34 + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.35 + *
    1.36 + */
    1.37 +
    1.38 +#include "regguts.h"
    1.39 +
    1.40 +/*
    1.41 + - regcomp - compile regular expression
    1.42 + */
    1.43 +int
    1.44 +regcomp(re, str, flags)
    1.45 +regex_t *re;
    1.46 +CONST char *str;
    1.47 +int flags;
    1.48 +{
    1.49 +	size_t len;
    1.50 +	int f = flags;
    1.51 +
    1.52 +	if (f&REG_PEND) {
    1.53 +		len = re->re_endp - str;
    1.54 +		f &= ~REG_PEND;
    1.55 +	} else
    1.56 +		len = strlen(str);
    1.57 +
    1.58 +	return re_comp(re, str, len, f);
    1.59 +}
    1.60 +
    1.61 +/*
    1.62 + - regexec - execute regular expression
    1.63 + */
    1.64 +int
    1.65 +regexec(re, str, nmatch, pmatch, flags)
    1.66 +regex_t *re;
    1.67 +CONST char *str;
    1.68 +size_t nmatch;
    1.69 +regmatch_t pmatch[];
    1.70 +int flags;
    1.71 +{
    1.72 +	CONST char *start;
    1.73 +	size_t len;
    1.74 +	int f = flags;
    1.75 +
    1.76 +	if (f&REG_STARTEND) {
    1.77 +		start = str + pmatch[0].rm_so;
    1.78 +		len = pmatch[0].rm_eo - pmatch[0].rm_so;
    1.79 +		f &= ~REG_STARTEND;
    1.80 +	} else {
    1.81 +		start = str;
    1.82 +		len = strlen(str);
    1.83 +	}
    1.84 +
    1.85 +	return re_exec(re, start, len, nmatch, pmatch, f);
    1.86 +}