-
Tom Lane authored
(extracted from Tcl 8.4.1 release, as Henry still hasn't got round to making it a separate library). This solves a performance problem for multibyte, as well as upgrading our regexp support to match recent Tcl and nearly match recent Perl.
Tom Lane authored(extracted from Tcl 8.4.1 release, as Henry still hasn't got round to making it a separate library). This solves a performance problem for multibyte, as well as upgrading our regexp support to match recent Tcl and nearly match recent Perl.
regcomp.c 54.42 KiB
/*
* re_*comp and friends - compile REs
* This file #includes several others (see the bottom).
*
* Copyright (c) 1998, 1999 Henry Spencer. All rights reserved.
*
* Development of this software was funded, in part, by Cray Research Inc.,
* UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
* Corporation, none of whom are responsible for the results. The author
* thanks all of them.
*
* Redistribution and use in source and binary forms -- with or without
* modification -- are permitted for any purpose, provided that
* redistributions in source form retain this entire copyright notice and
* indicate the origin and nature of any modifications.
*
* I'd appreciate being given credit for this package in the documentation
* of software which uses it, but that is not a requirement.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Header: /cvsroot/pgsql/src/backend/regex/regcomp.c,v 1.36 2003/02/05 17:41:33 tgl Exp $
*
*/
#include "regex/regguts.h"
/*
* forward declarations, up here so forward datatypes etc. are defined early
*/
/* === regcomp.c === */
static void moresubs (struct vars *, int);
static int freev (struct vars *, int);
static void makesearch (struct vars *, struct nfa *);
static struct subre *parse (struct vars *, int, int, struct state *, struct state *);
static struct subre *parsebranch (struct vars *, int, int, struct state *, struct state *, int);
static void parseqatom (struct vars *, int, int, struct state *, struct state *, struct subre *);
static void nonword (struct vars *, int, struct state *, struct state *);
static void word (struct vars *, int, struct state *, struct state *);
static int scannum (struct vars *);
static void repeat (struct vars *, struct state *, struct state *, int, int);
static void bracket (struct vars *, struct state *, struct state *);
static void cbracket (struct vars *, struct state *, struct state *);
static void brackpart (struct vars *, struct state *, struct state *);
static chr *scanplain (struct vars *);
static void leaders (struct vars *, struct cvec *);
static void onechr (struct vars *, chr, struct state *, struct state *);
static void dovec (struct vars *, struct cvec *, struct state *, struct state *);
static celt nextleader (struct vars *, chr, chr);
static void wordchrs (struct vars *);
static struct subre *subre (struct vars *, int, int, struct state *, struct state *);
static void freesubre (struct vars *, struct subre *);
static void freesrnode (struct vars *, struct subre *);
static void optst (struct vars *, struct subre *);
static int numst (struct subre *, int);
static void markst (struct subre *);
static void cleanst (struct vars *);
static long nfatree (struct vars *, struct subre *, FILE *);
static long nfanode (struct vars *, struct subre *, FILE *);
static int newlacon (struct vars *, struct state *, struct state *, int);
static void freelacons (struct subre *, int);