[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
regex module broken (was Re: cvs TRUNK broken for FreeBSD 4.11-RELEASE-p
From: |
Derek R. Price |
Subject: |
regex module broken (was Re: cvs TRUNK broken for FreeBSD 4.11-RELEASE-p11) |
Date: |
Thu, 13 Apr 2006 14:04:50 -0400 |
User-agent: |
Thunderbird 1.5 (Windows/20051201) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
Looks like Paul's recent regex changes broke compilation under at
least FreeBSD. The base problem appears to be using the C99 wctype_t
without protection when <wctype.h> may not have been present and
therefore not included.
Regards,
Derek
Mark D. Baushke wrote:
> Hi Derek,
>
> I am unable to build after the recent update to the regular expression
> stuff.
>
> -- Mark
>
> % cvs checkout ccvs
> % cd ccvs
> % ./configure
> checking for a BSD-compatible install... /usr/bin/install -c
> checking whether build environment is sane... yes
> checking for gawk... gawk
> checking whether make sets $(MAKE)... yes
> checking for prefix by checking for cvs... /usr/local/bin/cvs
> checking whether to enable maintainer-specific portions of Makefiles... no
> checking for ranlib... ranlib
> checking for style of include used by make... GNU
> checking for gcc... gcc
> checking for C compiler default output file name... a.out
> checking whether the C compiler works... yes
> checking whether we are cross compiling... no
> checking for suffix of executables...
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether gcc accepts -g... yes
> checking for gcc option to accept ANSI C... none needed
> checking dependency style of gcc... gcc
> checking how to run the C preprocessor... gcc -E
> checking for egrep... grep -E
> checking for AIX... no
> checking for ANSI C header files... yes
> checking for sys/types.h... yes
> checking for sys/stat.h... yes
> checking for stdlib.h... yes
> checking for string.h... yes
> checking for memory.h... yes
> checking for strings.h... yes
> checking for inttypes.h... yes
> checking for stdint.h... no
> checking for unistd.h... yes
> checking minix/config.h usability... no
> checking minix/config.h presence... no
> checking for minix/config.h... no
> checking whether it is safe to define __EXTENSIONS__... yes
> checking for gcc... (cached) gcc
> checking whether we are using the GNU C compiler... (cached) yes
> checking whether gcc accepts -g... (cached) yes
> checking for gcc option to accept ANSI C... (cached) none needed
> checking dependency style of gcc... (cached) gcc
> checking whether gcc and cc understand -c and -o together... yes
> checking for library containing strerror... none required
> checking for ranlib... (cached) ranlib
> checking whether ln -s works... yes
> checking for special C compiler options needed for large files... no
> checking for _FILE_OFFSET_BITS value needed for large files... no
> checking for _LARGE_FILES value needed for large files... no
> checking for perl... /usr/local/bin/perl
> checking for csh... /bin/csh
> checking for mktemp... /usr/bin/mktemp
> checking for sendmail... /usr/local/sbin/sendmail
> checking for pr... /usr/bin/pr
> checking for groff... /usr/bin/groff
> checking for ps2pdf... /usr/local/bin/ps2pdf
> checking for texi2dvi...
/b/mdb/prevent/ccvs-1.12.13.1.20060412/build-aux/missing texi2dvi
> checking whether #! works in shell scripts... yes
> checking for BSD VPATH bug in make... yes
> checking for dirent.h that defines DIR... yes
> checking for library containing opendir... none required
> checking for ANSI C header files... (cached) yes
> checking for sys/wait.h that is POSIX.1 compatible... yes
> checking direct.h usability... no
> checking direct.h presence... no
> checking for direct.h... no
> checking fcntl.h usability... yes
> checking fcntl.h presence... yes
> checking for fcntl.h... yes
> checking io.h usability... no
> checking io.h presence... no
> checking for io.h... no
> checking for memory.h... (cached) yes
> checking ndbm.h usability... yes
> checking ndbm.h presence... yes
> checking for ndbm.h... yes
> checking for stdint.h... (cached) no
> checking syslog.h usability... yes
> checking syslog.h presence... yes
> checking for syslog.h... yes
> checking sys/bsdtypes.h usability... no
> checking sys/bsdtypes.h presence... no
> checking for sys/bsdtypes.h... no
> checking sys/file.h usability... yes
> checking sys/file.h presence... yes
> checking for sys/file.h... yes
> checking sys/param.h usability... yes
> checking sys/param.h presence... yes
> checking for sys/param.h... yes
> checking sys/resource.h usability... yes
> checking sys/resource.h presence... yes
> checking for sys/resource.h... yes
> checking sys/select.h usability... yes
> checking sys/select.h presence... yes
> checking for sys/select.h... yes
> checking utime.h usability... yes
> checking utime.h presence... yes
> checking for utime.h... yes
> checking whether stat file-mode macros are broken... no
> checking for an ANSI C-conforming const... yes
> checking for uid_t in sys/types.h... yes
> checking for mode_t... yes
> checking for pid_t... yes
> checking return type of signal handlers... void
> checking for struct stat.st_blksize... yes
> checking for struct stat.st_rdev... yes
> checking for _LARGEFILE_SOURCE value needed for large files... no
> checking for fseeko... yes
> checking for waitpid... yes
> checking for fcntl.h... (cached) yes
> checking whether select hangs on /dev/null fd when timeout is NULL... yes
> checking for fcntl.h... (cached) yes
> checking for unistd.h... (cached) yes
> checking for working alloca.h... no
> checking for alloca... yes
> checking for stdlib.h... (cached) yes
> checking for GNU libc compatible malloc... yes
> checking for long long... yes
> checking for long double... yes
> checking for C/C++ restrict keyword... __restrict
> checking for IPv4 sockets... yes
> checking for IPv6 sockets... yes
> checking sys/socket.h usability... yes
> checking sys/socket.h presence... yes
> checking for sys/socket.h... yes
> checking netinet/in.h usability... yes
> checking netinet/in.h presence... yes
> checking for netinet/in.h... yes
> checking netdb.h usability... yes
> checking netdb.h presence... yes
> checking for netdb.h... yes
> checking sys/time.h usability... yes
> checking sys/time.h presence... yes
> checking for sys/time.h... yes
> checking for unistd.h... (cached) yes
> checking for sys/param.h... (cached) yes
> checking stdio_ext.h usability... no
> checking stdio_ext.h presence... no
> checking for stdio_ext.h... no
> checking termios.h usability... yes
> checking termios.h presence... yes
> checking for termios.h... yes
> checking sys/cdefs.h usability... yes
> checking sys/cdefs.h presence... yes
> checking for sys/cdefs.h... yes
> checking for inttypes.h... (cached) yes
> checking wchar.h usability... yes
> checking wchar.h presence... yes
> checking for wchar.h... yes
> checking wctype.h usability... yes
> checking wctype.h presence... yes
> checking for wctype.h... yes
> checking locale.h usability... yes
> checking locale.h presence... yes
> checking for locale.h... yes
> checking for inline... inline
> configure: checking how to do getaddrinfo
> checking for library containing getaddrinfo... none required
> checking for getaddrinfo... yes
> checking for gai_strerror... yes
> checking for library containing gethostbyname... none required
> checking for library containing getservbyname... none required
> checking whether getaddrinfo is declared... yes
> checking whether freeaddrinfo is declared... yes
> checking whether gai_strerror is declared... yes
> checking for struct addrinfo... yes
> checking for stdbool.h that conforms to C99... no
> checking for _Bool... no
> checking for fdopendir... no
> checking for fchdir... yes
> checking for mempcpy... no
> checking for isascii... yes
> checking for __fsetlocking... no
> checking for tcgetattr... yes
> checking for tcsetattr... yes
> checking for gettimeofday... yes
> checking for nanotime... no
> checking for getlogin_r... yes
> checking for getpwnam_r... no
> checking for mbsinit... no
> checking for alarm... yes
> checking for siginterrupt... yes
> checking for posix_memalign... no
> checking for iswprint... no
> checking for isblank... yes
> checking for mbrtowc... no
> checking for wcrtomb... no
> checking for wcscoll... no
> checking for mblen... yes
> checking for mbrlen... no
> checking for tzset... yes
> checking whether memrchr is declared... no
> checking whether system is Windows or MSDOS... no
> checking whether strerror_r is declared... yes
> checking for strerror_r... yes
> checking whether strerror_r returns char *... no
> checking for mbstate_t... yes
> checking whether getcwd (NULL, 0) allocates memory for result... yes
> checking whether getcwd is declared... yes
> checking for d_ino member in directory struct... yes
> checking whether time.h and sys/time.h may both be included... yes
> checking for struct timespec... yes
> checking whether nanosleep is declared... yes
> checking for compound literals... yes
> checking whether struct tm is in sys/time.h or time.h... time.h
> checking for library containing clock_gettime... none required
> checking for clock_gettime... yes
> checking for clock_settime... yes
> checking for struct tm.tm_gmtoff... yes
> checking whether getdelim is declared... no
> checking whether getlogin is declared... yes
> checking whether getlogin_r is declared... yes
> checking for ssize_t... yes
> checking getopt.h usability... no
> checking getopt.h presence... no
> checking for getopt.h... no
> checking whether getenv is declared... yes
> checking whether getpass is declared... yes
> checking whether fflush_unlocked is declared... no
> checking whether flockfile is declared... yes
> checking whether fputs_unlocked is declared... no
> checking whether funlockfile is declared... yes
> checking whether putc_unlocked is declared... yes
> checking for d_type member in directory struct... yes
> checking whether the preprocessor supports include_next... yes
> checking whether strtoimax is declared... no
> checking whether strtoumax is declared... no
> checking whether lstat dereferences a symlink specified with a trailing
slash... no
> checking whether mbrtowc and mbstate_t are properly declared... no
> checking whether byte ordering is bigendian... no
> checking whether <limits.h> defines MIN and MAX... no
> checking whether <sys/param.h> defines MIN and MAX... yes
> checking for inttypes.h... no
> checking for stdint.h... no
> checking for unsigned long long... yes
> checking for working mktime... no
> checking for stdlib.h... (cached) yes
> checking for unistd.h... (cached) yes
> checking for getpagesize... yes
> checking for working mmap... yes
> checking for MAP_ANONYMOUS... yes
> checking for nl_langinfo and CODESET... yes
> checking for inttypes.h... yes
> checking whether strdup is declared... yes
> checking for strftime... yes
> checking whether clearerr_unlocked is declared... yes
> checking whether feof_unlocked is declared... yes
> checking whether ferror_unlocked is declared... yes
> checking whether fgets_unlocked is declared... no
> checking whether fputc_unlocked is declared... no
> checking whether fread_unlocked is declared... no
> checking whether fwrite_unlocked is declared... no
> checking whether getc_unlocked is declared... yes
> checking whether getchar_unlocked is declared... yes
> checking whether putchar_unlocked is declared... yes
> checking for EOVERFLOW... yes
> checking for signed... yes
> checking for wchar_t... yes
> checking for wint_t... yes
> checking for size_t... yes
> checking for intmax_t... no
> checking for atexit... yes
> checking for sys/param.h... (cached) yes
> checking for resolvepath... no
> checking for canonicalize_file_name... no
> checking whether this system has an arbitrary file name length limit... yes
> checking for mempcpy... (cached) no
> checking for openat... no
> checking for memrchr... no
> checking for dup2... yes
> checking for working POSIX fnmatch... yes
> checking for stdio_ext.h... (cached) no
> checking for __fpending... no
> checking whether __fpending is declared... no
> checking how to determine the number of pending output bytes on a
stream... fp->_p - fp->_bf._base
> checking for ftruncate... yes
> configure: checking how to do getaddrinfo
> checking for library containing getaddrinfo... (cached) none required
> checking for getaddrinfo... (cached) yes
> checking for gai_strerror... (cached) yes
> checking for library containing gethostbyname... (cached) none required
> checking for library containing getservbyname... (cached) none required
> checking whether getaddrinfo is declared... (cached) yes
> checking whether freeaddrinfo is declared... (cached) yes
> checking whether gai_strerror is declared... (cached) yes
> checking for struct addrinfo... (cached) yes
> checking whether getcwd handles long file names properly... no, but it
is partly working
> checking for struct tm.tm_zone... yes
> checking for getdelim... no
> checking for flockfile... yes
> checking for funlockfile... yes
> checking for gethostname... yes
> checking whether getline is declared... no
> checking for getline... no
> checking for getdelim... (cached) no
> checking for flockfile... (cached) yes
> checking for funlockfile... (cached) yes
> checking for getlogin_r... (cached) yes
> checking OS.h usability... no
> checking OS.h presence... no
> checking for OS.h... no
> checking for getpagesize... (cached) yes
> checking whether gettimeofday clobbers localtime buffer... no
> checking glob.h usability... yes
> checking glob.h presence... yes
> checking for glob.h... yes
> checking for GNU glob interface version 1... no
> ./configure: line 22896: test: =: unary operator expected
> checking for stdlib.h... (cached) yes
> checking for GNU libc compatible malloc... (cached) yes
> checking for memchr... yes
> checking for memmove... yes
> checking for mempcpy... (cached) no
> checking for memrchr... (cached) no
> checking whether mkdir fails due to a trailing slash... no
> checking for mkstemp... yes
> checking for mkstemp limitations... no
> checking for library containing nanosleep... none required
> checking whether nanosleep works... yes
> checking for openat... (cached) no
> checking for mbstate_t... (cached) yes
> checking whether mbrtowc and mbstate_t are properly declared... (cached) no
> checking for readlink... yes
> checking for stdlib.h... (cached) yes
> checking for GNU libc compatible realloc... yes
> checking for working re_compile_pattern... no
> checking whether rename is broken... no
> checking for C/C++ restrict keyword... (cached) __restrict
> checking for rpmatch... no
> checking for setenv... yes
> checking for unsetenv... yes
> checking for unsetenv() return type... void
> checking for stdint.h... (cached) no
> checking for SIZE_MAX... 4294967295U
> checking for socklen_t... yes
> checking for ssize_t... (cached) yes
> checking sys/inttypes.h usability... yes
> checking sys/inttypes.h presence... yes
> checking for sys/inttypes.h... yes
> checking sys/bitypes.h usability... no
> checking sys/bitypes.h presence... no
> checking for sys/bitypes.h... no
> checking for stdint.h... (cached) no
> checking whether 'long' is 64 bit wide... no
> checking whether 'long long' is 64 bit wide... yes
> checking for strncasecmp... yes
> checking for strdup... yes
> checking for strerror... yes
> checking whether <inttypes.h> defines strtoimax as a macro... no
> checking for strtoimax... no
> checking whether strtoll is declared... yes
> checking for strtol... yes
> checking for strtoll... yes
> checking for strtoul... yes
> checking for strtoull... yes
> checking whether <inttypes.h> defines strtoumax as a macro... no
> checking for strtoumax... no
> checking whether strtoull is declared... yes
> checking whether localtime_r is compatible with its POSIX signature... yes
> checking for struct timespec... (cached) yes
> checking whether nanosleep is declared... (cached) yes
> checking whether tzset clobbers localtime buffer... no
> checking for unistd.h... (cached) yes
> checking for vasnprintf... no
> checking for ptrdiff_t... yes
> checking for snprintf... yes
> checking for wcslen... yes
> checking for vasprintf... yes
> checking for stdint.h... (cached) no
> checking whether NLS is requested... yes
> checking for msgfmt... /usr/local/bin/msgfmt
> checking for gmsgfmt... /usr/local/bin/msgfmt
> checking for xgettext... /usr/local/bin/xgettext
> checking for msgmerge... /usr/local/bin/msgmerge
> checking build system type... i386-unknown-freebsd4.11
> checking host system type... i386-unknown-freebsd4.11
> checking for ld used by GCC... /usr/libexec/elf/ld
> checking if the linker (/usr/libexec/elf/ld) is GNU ld... yes
> checking for shared library run path origin... done
> checking for CFPreferencesCopyAppValue... no
> checking for CFLocaleCopyCurrent... no
> checking whether NLS is requested... yes
> checking for GNU gettext in libc... no
> checking for iconv... yes
> checking how to link with libiconv... /usr/local/lib/libiconv.so
-Wl,-rpath -Wl,/usr/local/lib
> checking for GNU gettext in libintl... yes
> checking whether to use NLS... yes
> checking where the gettext function comes from... external libintl
> checking how to link with libintl... /usr/local/lib/libintl.so
-Wl,-rpath -Wl,/usr/local/lib
> checking whether strerror_r is declared... (cached) yes
> checking for strerror_r... (cached) yes
> checking whether strerror_r returns char *... (cached) no
> checking for fchdir... (cached) yes
> checking for fchmod... yes
> checking for fsync... yes
> checking for ftime... no
> checking for geteuid... yes
> checking for getgroups... yes
> checking for getpagesize... (cached) yes
> checking for gettimeofday... (cached) yes
> checking for initgroups... yes
> checking for login... no
> checking for logout... no
> checking for mknod... yes
> checking for regcomp... yes
> checking for regerror... yes
> checking for regexec... yes
> checking for regfree... yes
> checking for sigaction... yes
> checking for sigblock... yes
> checking for sigprocmask... yes
> checking for sigsetmask... yes
> checking for sigvec... yes
> checking for timezone... yes
> checking for tzset... (cached) yes
> checking for vprintf... yes
> checking for wait3... yes
> checking for char... yes
> checking size of char... 1
> checking for uniquely sized char... yes(1)
> checking for short... yes
> checking size of short... 2
> checking for uniquely sized short... yes(2)
> checking for int... yes
> checking size of int... 4
> checking for uniquely sized int... yes(4)
> checking for long... yes
> checking size of long... 4
> checking for uniquely sized long... no
> checking for long long... (cached) yes
> checking size of long long... 8
> checking for uniquely sized long long... yes(8)
> checking for size_t... (cached) yes
> checking size of size_t... 4
> checking for uniquely sized size_t... no
> checking for ptrdiff_t... (cached) yes
> checking size of ptrdiff_t... 4
> checking for uniquely sized ptrdiff_t... no
> checking for wint_t... yes
> checking size of wint_t... 4
> checking for uniquely sized wint_t... no
> checking for float... yes
> checking size of float... 4
> checking for uniquely sized float... yes(4)
> checking for double... yes
> checking size of double... 8
> checking for uniquely sized double... yes(8)
> checking for long double... yes
> checking size of long double... 12
> checking for uniquely sized long double... yes(12)
> checking for unistd.h... (cached) yes
> checking vfork.h usability... no
> checking vfork.h presence... no
> checking for vfork.h... no
> checking for fork... yes
> checking for vfork... yes
> checking for working fork... yes
> checking for working vfork... (cached) yes
> checking whether closedir returns void... no
> checking for library containing getspnam... no
> checking whether utime accepts a null argument... yes
> checking for long file names... yes
> checking whether printf supports %p... yes
> checking for main in -lnsl... no
> checking for library containing connect... none required
> checking for library containing gethostbyname... (cached) none required
> checking for KRB4 in /usr/kerberos...
> checking for krb.h...
> checking for krb_get_err_text... no
> checking for GSSAPI...
> checking gssapi.h usability... no
> checking gssapi.h presence... no
> checking for gssapi.h... no
> checking gssapi/gssapi.h usability... no
> checking gssapi/gssapi.h presence... no
> checking for gssapi/gssapi.h... no
> checking krb5.h usability... no
> checking krb5.h presence... no
> checking for krb5.h... no
> checking for GSSAPI in /usr/kerberos...
> checking gssapi.h usability... no
> checking gssapi.h presence... no
> checking for gssapi.h... no
> checking gssapi/gssapi.h usability... no
> checking gssapi/gssapi.h presence... no
> checking for gssapi/gssapi.h... no
> checking krb5.h usability... no
> checking krb5.h presence... no
> checking for krb5.h... no
> checking for GSSAPI in /usr/cygnus/kerbnet...
> checking gssapi.h usability... no
> checking gssapi.h presence... no
> checking for gssapi.h... no
> checking gssapi/gssapi.h usability... no
> checking gssapi/gssapi.h presence... no
> checking for gssapi/gssapi.h... no
> checking krb5.h usability... no
> checking krb5.h presence... no
> checking for krb5.h... no
> checking for GSSAPI... no
> checking for external ZLIB...
> checking zlib.h usability... yes
> checking zlib.h presence... yes
> checking for zlib.h... yes
> checking for external ZLIB... yes
> checking selected ZLIB... package
> checking for ssh... ssh
> checking for vim... vim
> checking for temporary directory... /tmp
> checking for library containing crypt... -lcrypt
> checking for a case sensitive file system... yes
> checking for cygwin32... no
> configure: creating ./config.status
> config.status: creating contrib/clmerge
> config.status: creating contrib/cln_hist
> config.status: creating contrib/commit_prep
> config.status: creating contrib/cvs_acls
> config.status: creating contrib/log_accum
> config.status: creating contrib/log
> config.status: creating contrib/mfpipe
> config.status: creating contrib/pvcs2rcs
> config.status: creating contrib/rcs2log
> config.status: creating contrib/rcslock
> config.status: creating contrib/sccs2rcs
> config.status: creating contrib/validate_repo
> config.status: creating doc/mkman
> config.status: creating src/cvsbug
> config.status: creating Makefile
> config.status: creating contrib/Makefile
> config.status: creating contrib/pam/Makefile
> config.status: creating cvs.spec
> config.status: creating diff/Makefile
> config.status: creating doc/Makefile
> config.status: creating doc/i18n/Makefile
> config.status: creating doc/i18n/pt_BR/Makefile
> config.status: creating emx/Makefile
> config.status: creating lib/Makefile
> config.status: creating maint-aux/Makefile
> config.status: creating man/Makefile
> config.status: creating os2/Makefile
> config.status: creating src/Makefile
> config.status: creating src/sanity.config.sh
> config.status: creating tools/Makefile
> config.status: creating vms/Makefile
> config.status: creating windows-NT/Makefile
> config.status: creating windows-NT/SCC/Makefile
> config.status: creating zlib/Makefile
> config.status: creating config.h
> config.status: executing depfiles commands
> config.status: executing default-1 commands
>
> You are about to use an unreleased version of CVS. Be sure to
> read the relevant mailing lists, most importantly <address@hidden>.
>
> Below you will find information on the status of this version of CVS.
>
>
> * Status
>
> This experimental version of CVS contains new features which may not have
> been tested as thoroughly as the stable release. It is classified as:
>
> /*-------------.
> | Experimental |
> `-------------*/
>
> /*-------------------------.
> | Sane for full scale use. |
> `-------------------------*/
>
> % gmake
> gmake all-recursive
> gmake[1]: Entering directory `/b/mdb/prevent/ccvs-1.12.13.1.20060412'
> Making all in lib
> gmake[2]: Entering directory `/b/mdb/prevent/ccvs-1.12.13.1.20060412/lib'
> cp ./alloca_.h alloca.h-t
> mv alloca.h-t alloca.h
> cp ./getopt_.h getopt.h-t
> mv getopt.h-t getopt.h
> cp ./glob_.h glob.h-t
> mv glob.h-t glob.h
> sed -e 's/@''HAVE__BOOL''@/0/g' \
> < ./stdbool_.h > stdbool.h-t
> mv stdbool.h-t stdbool.h
> sed -e 's/@''HAVE_LONG_64BIT''@/0/g;s/@''HAVE_LONG_LONG_64BIT@/1/g' <
./stdint_.h > stdint.h-t
> mv stdint.h-t stdint.h
> gmake all-am
> gmake[3]: Entering directory `/b/mdb/prevent/ccvs-1.12.13.1.20060412/lib'
> source='sighandle.c' object='sighandle.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c sighandle.c
> source='allocsa.c' object='allocsa.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c allocsa.c
> source='cycle-check.c' object='cycle-check.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c cycle-check.c
> source='basename.c' object='basename.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c basename.c
> source='stripslash.c' object='stripslash.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c stripslash.c
> source='getnline.c' object='getnline.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getnline.c
> source='strnlen1.c' object='strnlen1.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c strnlen1.c
> source='xalloc-die.c' object='xalloc-die.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c xalloc-die.c
> source='xgethostname.c' object='xgethostname.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c xgethostname.c
> source='sunos57-select.c' object='sunos57-select.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c sunos57-select.c
> source='save-cwd.c' object='save-cwd.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c save-cwd.c
> source='lstat.c' object='lstat.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c lstat.c
> source='mktime.c' object='mktime.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c mktime.c
> source='strftime.c' object='strftime.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c strftime.c
> source='canon-host.c' object='canon-host.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c canon-host.c
> source='canonicalize.c' object='canonicalize.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c canonicalize.c
> source='chdir-long.c' object='chdir-long.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c chdir-long.c
> source='mempcpy.c' object='mempcpy.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c mempcpy.c
> source='mkdirat.c' object='mkdirat.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c mkdirat.c
> source='openat-die.c' object='openat-die.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c openat-die.c
> source='openat.c' object='openat.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c openat.c
> source='memrchr.c' object='memrchr.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c memrchr.c
> source='closeout.c' object='closeout.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c closeout.c
> source='dirname.c' object='dirname.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c dirname.c
> source='exitfail.c' object='exitfail.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c exitfail.c
> source='open-safer.c' object='open-safer.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c open-safer.c
> source='creat-safer.c' object='creat-safer.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c creat-safer.c
> source='filenamecat.c' object='filenamecat.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c filenamecat.c
> source='__fpending.c' object='__fpending.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c __fpending.c
> source='getcwd.c' object='getcwd.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getcwd.c
> source='getdate.c' object='getdate.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getdate.c
> source='getdelim.c' object='getdelim.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getdelim.c
> source='getline.c' object='getline.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getline.c
> source='getndelim2.c' object='getndelim2.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getndelim2.c
> source='getopt.c' object='getopt.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getopt.c
> source='getopt1.c' object='getopt1.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getopt1.c
> source='getpass.c' object='getpass.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c getpass.c
> source='gettime.c' object='gettime.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c gettime.c
> source='glob.c' object='glob.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c glob.c
> source='mbchar.c' object='mbchar.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c mbchar.c
> source='md5.c' object='md5.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c md5.c
> source='pagealign_alloc.c' object='pagealign_alloc.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c pagealign_alloc.c
> source='quotearg.c' object='quotearg.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c quotearg.c
> source='regex.c' object='regex.o' libtool=no \
> DEPDIR=.deps depmode=gcc /bin/bash ../build-aux/depcomp \
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -Ino/include
-g -O2 -c regex.c
> In file included from regex.c:63:
> regcomp.c: In function `init_dfa':
> regcomp.c:846: `wctype_t' undeclared (first use in this function)
> regcomp.c:846: (Each undeclared identifier is reported only once
> regcomp.c:846: for each function it appears in.)
> gmake[3]: *** [regex.o] Error 1
> gmake[3]: Leaving directory `/b/mdb/prevent/ccvs-1.12.13.1.20060412/lib'
> gmake[2]: *** [all] Error 2
> gmake[2]: Leaving directory `/b/mdb/prevent/ccvs-1.12.13.1.20060412/lib'
> gmake[1]: *** [all-recursive] Error 1
> gmake[1]: Leaving directory `/b/mdb/prevent/ccvs-1.12.13.1.20060412'
> gmake: *** [all] Error 2
> % cd lib
> % source='regex.c' object='regex.o' libtool=no DEPDIR=.deps
depmode=gcc /bin/bash ../build-aux/depcomp gcc -DHAVE_CONFIG_H -I. -I.
-I.. -I/usr/local/include -Ino/include -g -O2 -E regex.c > regex.i
> % cat regex.i
> # 1 "regex.c"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "../config.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 21 "regex.c" 2
>
>
>
>
>
>
>
>
> # 52 "regex.c"
>
>
>
>
>
> # 1 "/usr/include/limits.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/sys/_posix.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 70 "/usr/include/sys/_posix.h"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 39 "/usr/include/limits.h" 2
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/machine/limits.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 94 "/usr/include/limits.h" 2
>
>
> # 1 "/usr/include/sys/syslimits.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 96 "/usr/include/limits.h" 2
>
>
>
>
> # 57 "regex.c" 2
>
>
> # 1 "regex.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/sys/types.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/sys/cdefs.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 106 "/usr/include/sys/cdefs.h"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 198 "/usr/include/sys/cdefs.h"
>
> # 215 "/usr/include/sys/cdefs.h"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 295 "/usr/include/sys/cdefs.h"
>
>
>
>
>
>
>
>
>
> # 324 "/usr/include/sys/cdefs.h"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 45 "/usr/include/sys/types.h" 2
>
>
>
> # 1 "/usr/include/sys/inttypes.h" 1
>
>
>
>
>
>
>
>
> # 1 "/usr/include/machine/ansi.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef int __attribute__((__mode__(__DI__))) __int64_t;
> typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
>
>
>
>
>
>
>
>
>
>
> typedef signed char __int8_t;
> typedef unsigned char __uint8_t;
> typedef short __int16_t;
> typedef unsigned short __uint16_t;
> typedef int __int32_t;
> typedef unsigned int __uint32_t;
>
> typedef int __intptr_t;
> typedef unsigned int __uintptr_t;
>
>
>
>
>
> typedef union {
> char __mbstate8[128];
> __int64_t _mbstateL;
> } __mbstate_t;
>
>
> # 9 "/usr/include/sys/inttypes.h" 2
>
>
> typedef __int8_t int8_t;
> typedef __int16_t int16_t;
> typedef __int32_t int32_t;
> typedef __int64_t int64_t;
>
> typedef __uint8_t uint8_t;
> typedef __uint16_t uint16_t;
> typedef __uint32_t uint32_t;
> typedef __uint64_t uint64_t;
>
> typedef __intptr_t intptr_t;
> typedef __uintptr_t uintptr_t;
>
>
> # 48 "/usr/include/sys/types.h" 2
>
> # 1 "/usr/include/machine/types.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef struct _physadr {
> int r[1];
> } *physadr;
>
> typedef struct label_t {
> int val[6];
> } label_t;
>
>
> typedef unsigned int vm_offset_t;
> typedef __int64_t vm_ooffset_t;
>
>
>
> typedef unsigned int vm_paddr_t;
>
> typedef unsigned int vm_pindex_t;
> typedef unsigned int vm_size_t;
>
> typedef __int32_t register_t;
> typedef __uint32_t u_register_t;
>
>
>
>
>
>
>
> typedef __uint32_t intrmask_t;
>
>
> typedef void inthand2_t (void *_cookie) ;
> typedef void ointhand2_t (int _device_id) ;
>
>
> # 49 "/usr/include/sys/types.h" 2
>
>
>
> typedef unsigned char u_char;
> typedef unsigned short u_short;
> typedef unsigned int u_int;
> typedef unsigned long u_long;
> typedef unsigned short ushort;
> typedef unsigned int uint;
>
>
> typedef __uint8_t u_int8_t;
> typedef __uint16_t u_int16_t;
> typedef __uint32_t u_int32_t;
> typedef __uint64_t u_int64_t;
>
> typedef u_int64_t u_quad_t;
> typedef int64_t quad_t;
> typedef quad_t * qaddr_t;
>
> typedef char * caddr_t;
> typedef const char * c_caddr_t;
> typedef volatile char *v_caddr_t;
> typedef int32_t daddr_t;
> typedef u_int32_t u_daddr_t;
> typedef u_int32_t fixpt_t;
> typedef u_int32_t gid_t;
> typedef u_int32_t in_addr_t;
> typedef u_int16_t in_port_t;
> typedef u_int32_t ino_t;
> typedef long key_t;
> typedef u_int16_t mode_t;
> typedef u_int16_t nlink_t;
> typedef __int64_t off_t;
> typedef int pid_t;
> typedef quad_t rlim_t;
>
>
>
> typedef int32_t segsz_t;
>
> typedef int32_t swblk_t;
> typedef int32_t ufs_daddr_t;
> typedef u_int32_t uid_t;
>
> # 106 "/usr/include/sys/types.h"
>
>
> typedef u_int32_t dev_t;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/machine/endian.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> unsigned long htonl (unsigned long) ;
> unsigned short htons (unsigned short) ;
> unsigned long ntohl (unsigned long) ;
> unsigned short ntohs (unsigned short) ;
>
>
>
>
>
>
>
>
>
> # 84 "/usr/include/machine/endian.h"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 126 "/usr/include/sys/types.h" 2
>
>
>
> typedef unsigned long clock_t;
>
>
>
>
> typedef int clockid_t;
>
>
>
>
> typedef unsigned int size_t;
>
>
>
>
> typedef int ssize_t;
>
>
>
>
> typedef long time_t;
>
>
>
>
> typedef int timer_t;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef unsigned long fd_mask;
>
>
>
>
>
>
> typedef struct fd_set {
> fd_mask fds_bits[((( 1024 ) + (( (sizeof(fd_mask) * 8 ) ) -
1)) / ( (sizeof(fd_mask) * 8 ) )) ];
> } fd_set;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> int ftruncate (int, off_t) ;
>
>
>
> off_t lseek (int, off_t, int) ;
>
>
>
> void * mmap (void *, size_t, int, int, int, off_t) ;
>
>
>
> int truncate (const char *, off_t) ;
>
>
>
>
>
>
>
> # 24 "regex.h" 2
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef ssize_t regoff_t;
>
>
>
>
> typedef size_t __re_idx_t;
>
>
> typedef size_t __re_size_t;
>
>
>
> typedef size_t __re_long_size_t;
>
> # 86 "regex.h"
>
>
>
>
>
>
> typedef long int s_reg_t;
> typedef unsigned long int active_reg_t;
>
>
>
>
>
>
> typedef unsigned long int reg_syntax_t;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> extern reg_syntax_t rpl_re_syntax_options ;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef enum
> {
> _REG_ENOSYS = -1,
> _REG_NOERROR = 0,
> _REG_NOMATCH,
>
>
>
> _REG_BADPAT,
> _REG_ECOLLATE,
> _REG_ECTYPE,
> _REG_EESCAPE,
> _REG_ESUBREG,
> _REG_EBRACK,
> _REG_EPAREN,
> _REG_EBRACE,
> _REG_BADBR,
> _REG_ERANGE,
> _REG_ESPACE,
> _REG_BADRPT,
>
>
> _REG_EEND,
> _REG_ESIZE,
> _REG_ERPAREN
> } reg_errcode_t;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> struct re_pattern_buffer
> {
>
>
>
> unsigned char * buffer ;
>
>
> __re_long_size_t allocated ;
>
>
> __re_long_size_t used ;
>
>
> reg_syntax_t syntax ;
>
>
>
>
> char * fastmap ;
>
>
>
>
>
> unsigned char * translate ;
>
>
> size_t re_nsub;
>
>
>
>
>
> unsigned int can_be_null : 1;
>
>
>
>
>
>
>
>
>
>
> unsigned int regs_allocated : 2;
>
>
>
> unsigned int fastmap_accurate : 1;
>
>
>
> unsigned int no_sub : 1;
>
>
>
> unsigned int not_bol : 1;
>
>
> unsigned int not_eol : 1;
>
>
> unsigned int newline_anchor : 1;
>
>
> };
>
> typedef struct re_pattern_buffer regex_t;
>
>
>
> struct re_registers
> {
> __re_size_t num_regs ;
> regoff_t * start ;
> regoff_t * end ;
> };
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef struct
> {
> regoff_t rm_so;
> regoff_t rm_eo;
> } regmatch_t;
>
>
>
>
>
> extern reg_syntax_t rpl_re_set_syntax (reg_syntax_t __syntax);
>
>
>
>
> extern const char * rpl_re_compile_pattern (const char *__pattern,
size_t __length,
> struct re_pattern_buffer *__buffer);
>
>
>
>
>
> extern int rpl_re_compile_fastmap (struct re_pattern_buffer *__buffer);
>
>
>
>
>
>
>
> extern regoff_t rpl_re_search (struct re_pattern_buffer *__buffer,
> const char *__string, __re_idx_t __length,
> __re_idx_t __start, regoff_t __range,
> struct re_registers *__regs);
>
>
>
>
> extern regoff_t rpl_re_search_2 (struct re_pattern_buffer *__buffer,
> const char *__string1, __re_idx_t __length1,
> const char *__string2, __re_idx_t __length2,
> __re_idx_t __start, regoff_t __range,
> struct re_registers *__regs,
> __re_idx_t __stop);
>
>
>
>
> extern regoff_t rpl_re_match (struct re_pattern_buffer *__buffer,
> const char *__string, __re_idx_t __length,
> __re_idx_t __start, struct re_registers *__regs);
>
>
>
> extern regoff_t rpl_re_match_2 (struct re_pattern_buffer *__buffer,
> const char *__string1, __re_idx_t __length1,
> const char *__string2, __re_idx_t __length2,
> __re_idx_t __start, struct re_registers *__regs,
> __re_idx_t __stop);
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> extern void rpl_re_set_registers (struct re_pattern_buffer *__buffer,
> struct re_registers *__regs,
> __re_size_t __num_regs,
> regoff_t *__starts, regoff_t *__ends);
>
>
>
>
> extern char * rpl_re_comp (const char *);
> extern int rpl_re_exec (const char *);
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> extern int rpl_regcomp (regex_t *__restrict __preg,
> const char *__restrict __pattern,
> int __cflags);
>
> extern int rpl_regexec (const regex_t *__restrict __preg,
> const char *__restrict __string, size_t __nmatch,
> regmatch_t __pmatch[ ],
> int __eflags);
>
> extern size_t rpl_regerror (int __errcode, const regex_t *__restrict
__preg,
> char *__restrict __errbuf, size_t __errbuf_size);
>
> extern void rpl_regfree (regex_t *__preg);
>
>
>
>
>
>
>
> # 59 "regex.c" 2
>
> # 1 "regex_internal.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/assert.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> void __assert (const char *, int, const char *) ;
>
> # 23 "regex_internal.h" 2
>
> # 1 "/usr/include/ctype.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/runetype.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef int rune_t;
>
>
>
>
>
>
>
>
>
>
> typedef int wchar_t;
>
>
>
>
>
>
>
>
>
>
> typedef struct {
> rune_t min;
> rune_t max;
> rune_t map;
> unsigned long *types;
> } _RuneEntry;
>
> typedef struct {
> int nranges;
> _RuneEntry *ranges;
> } _RuneRange;
>
> typedef struct {
> char magic[8];
> char encoding[32];
>
> rune_t (*sgetrune)
> (const char *, size_t, char const **) ;
> int (*sputrune)
> (rune_t, char *, size_t, char **) ;
> rune_t invalid_rune;
>
> unsigned long runetype[(1 <<8 ) ];
> rune_t maplower[(1 <<8 ) ];
> rune_t mapupper[(1 <<8 ) ];
>
>
>
>
>
>
> _RuneRange runetype_ext;
> _RuneRange maplower_ext;
> _RuneRange mapupper_ext;
>
> void *variable;
> int variable_len;
> } _RuneLocale;
>
>
>
> extern _RuneLocale _DefaultRuneLocale;
> extern _RuneLocale *_CurrentRuneLocale;
>
>
> # 52 "/usr/include/ctype.h" 2
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> int isalnum (int) ;
> int isalpha (int) ;
> int iscntrl (int) ;
> int isdigit (int) ;
> int isgraph (int) ;
> int islower (int) ;
> int isprint (int) ;
> int ispunct (int) ;
> int isspace (int) ;
> int isupper (int) ;
> int isxdigit (int) ;
> int tolower (int) ;
> int toupper (int) ;
>
>
> int digittoint (int) ;
> int isascii (int) ;
> int isblank (int) ;
> int ishexnumber (int) ;
> int isideogram (int) ;
> int isnumber (int) ;
> int isphonogram (int) ;
> int isrune (int) ;
> int isspecial (int) ;
> int toascii (int) ;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> unsigned long ___runetype (int ) ;
> int ___tolower (int ) ;
> int ___toupper (int ) ;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> static __inline int
> __maskrune(int _c, unsigned long _f)
> {
> return ((_c < 0 || _c >= (1 <<8 ) ) ? ___runetype(_c) :
> _CurrentRuneLocale->runetype[_c]) & _f;
> }
>
> static __inline int
> __isctype(int _c, unsigned long _f)
> {
> return (_c < 0 || _c >= (1 <<8 ) ) ? 0 :
> !!(_DefaultRuneLocale.runetype[_c] & _f);
> }
>
> static __inline int
> __toupper(int _c)
> {
> return (_c < 0 || _c >= (1 <<8 ) ) ? ___toupper(_c) :
> _CurrentRuneLocale->mapupper[_c];
> }
>
> static __inline int
> __tolower(int _c)
> {
> return (_c < 0 || _c >= (1 <<8 ) ) ? ___tolower(_c) :
> _CurrentRuneLocale->maplower[_c];
> }
>
> # 185 "/usr/include/ctype.h"
>
>
>
> # 24 "regex_internal.h" 2
>
> # 1 "stdbool.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 101 "stdbool.h"
>
>
>
> typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
>
>
>
>
>
>
>
>
>
>
>
> # 25 "regex_internal.h" 2
>
> # 1 "/usr/include/stdio.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef __int64_t fpos_t;
>
>
>
>
>
>
>
>
>
>
> struct __sbuf {
> unsigned char *_base;
> int _size;
> };
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef struct __sFILE {
> unsigned char *_p;
> int _r;
> int _w;
> short _flags;
> short _file;
> struct __sbuf _bf;
> int _lbfsize;
>
>
> void *_cookie;
> int (*_close) (void *) ;
> int (*_read) (void *, char *, int) ;
> fpos_t (*_seek) (void *, fpos_t, int) ;
> int (*_write) (void *, const char *, int) ;
>
>
> struct __sbuf _ub;
> unsigned char *_up;
> int _ur;
>
>
> unsigned char _ubuf[3];
> unsigned char _nbuf[1];
>
>
> struct __sbuf _lb;
>
>
> int _blksize;
> fpos_t _offset;
> } FILE;
>
>
> extern FILE *__stdinp, *__stdoutp, *__stderrp;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> void clearerr (FILE *) ;
> int fclose (FILE *) ;
> int feof (FILE *) ;
> int ferror (FILE *) ;
> int fflush (FILE *) ;
> int fgetc (FILE *) ;
> int fgetpos (FILE *, fpos_t *) ;
> char *fgets (char *, int, FILE *) ;
> FILE *fopen (const char *, const char *) ;
> int fprintf (FILE *, const char *, ...) ;
> int fputc (int, FILE *) ;
> int fputs (const char *, FILE *) ;
> size_t fread (void *, size_t, size_t, FILE *) ;
> FILE *freopen (const char *, const char *, FILE *) ;
> int fscanf (FILE *, const char *, ...) ;
> int fseek (FILE *, long, int) ;
> int fsetpos (FILE *, const fpos_t *) ;
> long ftell (FILE *) ;
> size_t fwrite (const void *, size_t, size_t, FILE *) ;
> int getc (FILE *) ;
> int getchar (void) ;
> char *gets (char *) ;
>
> extern const int sys_nerr;
> extern const char * const sys_errlist[];
>
> void perror (const char *) ;
> int printf (const char *, ...) ;
> int putc (int, FILE *) ;
> int putchar (int) ;
> int puts (const char *) ;
> int remove (const char *) ;
> int rename (const char *, const char *) ;
> void rewind (FILE *) ;
> int scanf (const char *, ...) ;
> void setbuf (FILE *, char *) ;
> int setvbuf (FILE *, char *, int, size_t) ;
> int sprintf (char *, const char *, ...) ;
> int sscanf (const char *, const char *, ...) ;
> FILE *tmpfile (void) ;
> char *tmpnam (char *) ;
> int ungetc (int, FILE *) ;
> int vfprintf (FILE *, const char *, char * ) ;
> int vprintf (const char *, char * ) ;
> int vsprintf (char *, const char *, char * ) ;
>
>
>
>
>
>
>
>
>
>
>
>
> char *ctermid (char *) ;
> FILE *fdopen (int, const char *) ;
> int fileno (FILE *) ;
> int ftrylockfile (FILE *) ;
> void flockfile (FILE *) ;
> void funlockfile (FILE *) ;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> int asprintf (char **, const char *, ...)
__attribute__((__format__ (__printf__, 2 , 3 ))) ;
> char *ctermid_r (char *) ;
> char *fgetln (FILE *, size_t *) ;
>
>
>
>
>
> const char *fmtcheck (const char *, const char *)
__attribute__((__format_arg__(2))) ;
> int fpurge (FILE *) ;
> int fseeko (FILE *, __int64_t , int) ;
> __int64_t ftello (FILE *) ;
> int getw (FILE *) ;
> int pclose (FILE *) ;
> FILE *popen (const char *, const char *) ;
> int putw (int, FILE *) ;
> void setbuffer (FILE *, char *, int) ;
> int setlinebuf (FILE *) ;
> char *tempnam (const char *, const char *) ;
> int snprintf (char *, size_t, const char *, ...)
__attribute__((__format__ (__printf__, 3 , 4 ))) ;
> int vasprintf (char **, const char *, char * )
> __attribute__((__format__ (__printf__, 2 , 0 ))) ;
> int vsnprintf (char *, size_t, const char *, char * )
> __attribute__((__format__ (__printf__, 3 , 0 ))) ;
> int vscanf (const char *, char * ) __attribute__((__format__
(__scanf__, 1 , 0 ))) ;
> int vsscanf (const char *, const char *, char * )
> __attribute__((__format__ (__scanf__, 2 , 0 ))) ;
>
>
>
>
>
>
>
>
>
>
>
>
>
> FILE *funopen (const void *,
> int (*)(void *, char *, int),
> int (*)(void *, const char *, int),
> fpos_t (*)(void *, fpos_t, int),
> int (*)(void *)) ;
>
>
>
>
>
>
>
>
>
> int __srget (FILE *) ;
> int __svfscanf (FILE *, const char *, char * ) ;
> int __swbuf (int, FILE *) ;
>
>
>
>
>
>
>
>
> static __inline int __sputc(int _c, FILE *_p) {
> if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
> return (*_p->_p++ = _c);
> else
> return (__swbuf(_c, _p));
> }
> # 379 "/usr/include/stdio.h"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 443 "/usr/include/stdio.h"
>
>
>
>
>
>
>
>
>
>
>
>
> # 26 "regex_internal.h" 2
>
> # 1 "/usr/include/stdlib.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef struct {
> int quot;
> int rem;
> } div_t;
>
> typedef struct {
> long quot;
> long rem;
> } ldiv_t;
>
>
>
>
>
>
>
>
>
>
> extern int __mb_cur_max;
>
>
>
> void abort (void) __attribute__((__noreturn__)) ;
> int abs (int) __attribute__((__const__)) ;
> int atexit (void (*)(void)) ;
> double atof (const char *) ;
> int atoi (const char *) ;
> long atol (const char *) ;
> void *bsearch (const void *, const void *, size_t,
> size_t, int (*)(const void *, const void *)) ;
> void *calloc (size_t, size_t) ;
> div_t div (int, int) __attribute__((__const__)) ;
> void exit (int) __attribute__((__noreturn__)) ;
> void free (void *) ;
> char *getenv (const char *) ;
> long labs (long) __attribute__((__const__)) ;
> ldiv_t ldiv (long, long) __attribute__((__const__)) ;
> void *malloc (size_t) ;
> void qsort (void *, size_t, size_t,
> int (*)(const void *, const void *)) ;
> int rand (void) ;
> void *realloc (void *, size_t) ;
> void srand (unsigned) ;
> double strtod (const char *, char **) ;
> long strtol (const char *, char **, int) ;
>
> long long
> strtoll (const char *, char **, int) ;
>
> unsigned long
> strtoul (const char *, char **, int) ;
>
> unsigned long long
> strtoull (const char *, char **, int) ;
>
> int system (const char *) ;
>
> int mblen (const char *, size_t) ;
> size_t mbstowcs (wchar_t *, const char *, size_t) ;
> int wctomb (char *, wchar_t) ;
> int mbtowc (wchar_t *, const char *, size_t) ;
> size_t wcstombs (char *, const wchar_t *, size_t) ;
>
>
> int putenv (const char *) ;
> int setenv (const char *, const char *, int) ;
>
> double drand48 (void) ;
> double erand48 (unsigned short[3]) ;
> long jrand48 (unsigned short[3]) ;
> void lcong48 (unsigned short[7]) ;
> long lrand48 (void) ;
> long mrand48 (void) ;
> long nrand48 (unsigned short[3]) ;
> unsigned short
> *seed48 (unsigned short[3]) ;
> void srand48 (long) ;
>
> void *alloca (size_t) ;
>
> __uint32_t
> arc4random (void) ;
> void arc4random_addrandom (unsigned char *dat, int datlen) ;
> void arc4random_stir (void) ;
> char *getbsize (int *, long *) ;
> char *cgetcap (char *, char *, int) ;
> int cgetclose (void) ;
> int cgetent (char **, char **, char *) ;
> int cgetfirst (char **, char **) ;
> int cgetmatch (char *, char *) ;
> int cgetnext (char **, char **) ;
> int cgetnum (char *, char *, long *) ;
> int cgetset (char *) ;
> int cgetstr (char *, char *, char **) ;
> int cgetustr (char *, char *, char **) ;
>
> int daemon (int, int) ;
> char *devname (int, int) ;
> int getloadavg (double [], int) ;
> const char *
> getprogname (void) ;
>
> char *group_from_gid (unsigned long, int) ;
> int heapsort (void *, size_t, size_t,
> int (*)(const void *, const void *)) ;
> char *initstate (unsigned long, char *, long) ;
> int mergesort (void *, size_t, size_t,
> int (*)(const void *, const void *)) ;
> int radixsort (const unsigned char **, int, const unsigned char *,
> unsigned) ;
> int sradixsort (const unsigned char **, int, const unsigned char *,
> unsigned) ;
> int rand_r (unsigned *) ;
> long random (void) ;
> void *reallocf (void *, size_t) ;
> char *realpath (const char *, char resolved_path[]) ;
> void setprogname (const char *) ;
> char *setstate (char *) ;
> void srandom (unsigned long) ;
> void srandomdev (void) ;
> char *user_from_uid (unsigned long, int) ;
>
> __int64_t strtoq (const char *, char **, int) ;
> __uint64_t
> strtouq (const char *, char **, int) ;
>
> void unsetenv (const char *) ;
>
>
>
>
> # 27 "regex_internal.h" 2
>
> # 1 "/usr/include/string.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> void *memchr (const void *, int, size_t) ;
> int memcmp (const void *, const void *, size_t) ;
> void *memcpy (void *, const void *, size_t) ;
> void *memmove (void *, const void *, size_t) ;
> void *memset (void *, int, size_t) ;
> char *strcat (char *, const char *) ;
> char *strchr (const char *, int) ;
> int strcmp (const char *, const char *) ;
> int strcoll (const char *, const char *) ;
> char *strcpy (char *, const char *) ;
> size_t strcspn (const char *, const char *) ;
> char *strerror (int) ;
> size_t strlen (const char *) ;
> char *strncat (char *, const char *, size_t) ;
> int strncmp (const char *, const char *, size_t) ;
> char *strncpy (char *, const char *, size_t) ;
> char *strpbrk (const char *, const char *) ;
> char *strrchr (const char *, int) ;
> size_t strspn (const char *, const char *) ;
> char *strstr (const char *, const char *) ;
> char *strtok (char *, const char *) ;
> size_t strxfrm (char *, const char *, size_t) ;
>
>
>
> int bcmp (const void *, const void *, size_t) ;
> void bcopy (const void *, void *, size_t) ;
> void bzero (void *, size_t) ;
> int ffs (int) ;
> char *index (const char *, int) ;
> void *memccpy (void *, const void *, int, size_t) ;
> char *rindex (const char *, int) ;
> int rpl_strcasecmp (const char *, const char *) ;
> char *strcasestr (const char *, const char *) ;
> char *strdup (const char *) ;
> int strerror_r (int, char *, size_t) ;
> size_t strlcat (char *, const char *, size_t) ;
> size_t strlcpy (char *, const char *, size_t) ;
> void strmode (int, char *) ;
> int strncasecmp (const char *, const char *, size_t) ;
> char *strnstr (const char *, const char *, size_t) ;
> char *strsep (char **, const char *) ;
> char *strsignal (int) ;
> char *strtok_r (char *, const char *, char **) ;
> void swab (const void *, void *, size_t) ;
>
>
>
>
> # 28 "regex_internal.h" 2
>
>
>
> # 1 "strcase.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/stddef.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef int ptrdiff_t;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 21 "strcase.h" 2
>
>
>
>
>
>
>
>
>
>
>
>
>
> extern int rpl_strcasecmp (const char *s1, const char *s2);
>
>
>
>
>
> extern int strncasecmp (const char *s1, const char *s2, size_t n);
>
>
>
>
>
>
>
>
> # 31 "regex_internal.h" 2
>
>
>
>
> # 1 "/usr/include/langinfo.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "/usr/include/nl_types.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef int nl_item;
> typedef void *nl_catd;
>
>
> extern nl_catd catopen (const char *, int) ;
> extern char *catgets (nl_catd, int, int, const char *) ;
> extern int catclose (nl_catd) ;
>
>
>
> # 33 "/usr/include/langinfo.h" 2
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> char *nl_langinfo (nl_item) ;
>
>
>
> # 35 "regex_internal.h" 2
>
>
>
> # 1 "/usr/include/locale.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> struct lconv {
> char *decimal_point;
> char *thousands_sep;
> char *grouping;
> char *int_curr_symbol;
> char *currency_symbol;
> char *mon_decimal_point;
> char *mon_thousands_sep;
> char *mon_grouping;
> char *positive_sign;
> char *negative_sign;
> char int_frac_digits;
> char frac_digits;
> char p_cs_precedes;
> char p_sep_by_space;
> char n_cs_precedes;
> char n_sep_by_space;
> char p_sign_posn;
> char n_sign_posn;
> };
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> struct lconv *localeconv (void) ;
> char *setlocale (int, const char *) ;
>
>
>
> # 38 "regex_internal.h" 2
>
>
>
> # 1 "/usr/include/wchar.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef __mbstate_t mbstate_t;
>
>
>
>
> typedef int wint_t;
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 112 "/usr/include/wchar.h"
>
> wchar_t *wcscat (wchar_t * __restrict, const wchar_t * __restrict) ;
> wchar_t *wcschr (const wchar_t *, wchar_t) ;
> int wcscmp (const wchar_t *, const wchar_t *) ;
> wchar_t *wcscpy (wchar_t * __restrict, const wchar_t * __restrict) ;
> size_t wcscspn (const wchar_t *, const wchar_t *) ;
> size_t wcslen (const wchar_t *) ;
> wchar_t *wcsncat (wchar_t * __restrict, const wchar_t * __restrict,
> size_t) ;
> int wcsncmp (const wchar_t *, const wchar_t *, size_t) ;
> wchar_t *wcsncpy (wchar_t * __restrict , const wchar_t * __restrict,
> size_t) ;
> wchar_t *wcspbrk (const wchar_t *, const wchar_t *) ;
> wchar_t *wcsrchr (const wchar_t *, wchar_t) ;
>
>
>
>
>
> size_t wcsspn (const wchar_t *, const wchar_t *) ;
> wchar_t *wcsstr (const wchar_t *, const wchar_t *) ;
> wchar_t *wmemchr (const wchar_t *, wchar_t, size_t) ;
> int wmemcmp (const wchar_t *, const wchar_t *, size_t) ;
> wchar_t *wmemcpy (wchar_t * __restrict, const wchar_t * __restrict,
> size_t) ;
> wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t) ;
> wchar_t *wmemset (wchar_t *, wchar_t, size_t) ;
>
> size_t wcslcat (wchar_t *, const wchar_t *, size_t) ;
> size_t wcslcpy (wchar_t *, const wchar_t *, size_t) ;
>
>
>
>
>
>
>
>
> # 41 "regex_internal.h" 2
>
>
>
> # 1 "/usr/include/wctype.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 66 "/usr/include/wctype.h"
>
> # 44 "regex_internal.h" 2
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef __re_idx_t Idx;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> typedef __re_size_t re_hashval_t;
>
>
>
> typedef unsigned long int bitset_word_t;
>
>
>
>
>
>
>
>
>
>
> # 202 "regex_internal.h"
>
>
>
>
>
> typedef bitset_word_t bitset_t[(((0xff + 1) + 32 - 1) / 32 ) ];
> typedef bitset_word_t *re_bitset_ptr_t;
> typedef const bitset_word_t *re_const_bitset_ptr_t;
>
>
>
>
>
>
>
>
>
>
>
>
> typedef enum
> {
> INSIDE_WORD = 0x0001 | 0x0004 ,
> WORD_FIRST = 0x0002 | 0x0004 ,
> WORD_LAST = 0x0001 | 0x0008 ,
> INSIDE_NOTWORD = 0x0002 | 0x0008 ,
> LINE_FIRST = 0x0010 ,
> LINE_LAST = 0x0020 ,
> BUF_FIRST = 0x0040 ,
> BUF_LAST = 0x0080 ,
> WORD_DELIM = 0x0100 ,
> NOT_WORD_DELIM = 0x0200
> } re_context_type;
>
> typedef struct
> {
> Idx alloc;
> Idx nelem;
> Idx *elems;
> } re_node_set;
>
> typedef enum
> {
> NON_TYPE = 0,
>
>
> CHARACTER = 1,
> END_OF_RE = 2,
> SIMPLE_BRACKET = 3,
> OP_BACK_REF = 4,
> OP_PERIOD = 5,
>
>
>
>
>
>
>
>
> OP_OPEN_SUBEXP = 8 | 0,
> OP_CLOSE_SUBEXP = 8 | 1,
> OP_ALT = 8 | 2,
> OP_DUP_ASTERISK = 8 | 3,
> ANCHOR = 8 | 4,
>
>
> CONCAT = 16,
> SUBEXP = 17,
>
>
> OP_DUP_PLUS = 18,
> OP_DUP_QUESTION,
> OP_OPEN_BRACKET,
> OP_CLOSE_BRACKET,
> OP_CHARSET_RANGE,
> OP_OPEN_DUP_NUM,
> OP_CLOSE_DUP_NUM,
> OP_NON_MATCH_LIST,
> OP_OPEN_COLL_ELEM,
> OP_CLOSE_COLL_ELEM,
> OP_OPEN_EQUIV_CLASS,
> OP_CLOSE_EQUIV_CLASS,
> OP_OPEN_CHAR_CLASS,
> OP_CLOSE_CHAR_CLASS,
> OP_WORD,
> OP_NOTWORD,
> OP_SPACE,
> OP_NOTSPACE,
> BACK_SLASH
>
> } re_token_type_t;
>
> # 340 "regex_internal.h"
>
>
> typedef struct
> {
> union
> {
> unsigned char c;
> re_bitset_ptr_t sbcset;
>
>
>
> Idx idx;
> re_context_type ctx_type;
> } opr;
>
> re_token_type_t type : 8;
>
>
>
> unsigned int constraint : 10;
> unsigned int duplicated : 1;
> unsigned int opt_subexp : 1;
>
>
>
>
>
>
> unsigned int word_char : 1;
> } re_token_t;
>
>
>
> struct re_string_t
> {
>
>
> const unsigned char *raw_mbs;
>
>
>
> unsigned char *mbs;
>
>
>
>
>
>
>
>
> Idx raw_mbs_idx;
>
> Idx valid_len;
>
> Idx valid_raw_len;
>
> Idx bufs_len;
>
> Idx cur_idx;
>
> Idx raw_len;
>
> Idx len;
>
>
>
> Idx raw_stop;
>
> Idx stop;
>
>
>
>
> unsigned int tip_context;
>
> unsigned char * trans;
>
> re_const_bitset_ptr_t word_char;
>
> unsigned char icase;
> unsigned char is_utf8;
> unsigned char map_notascii;
> unsigned char mbs_allocated;
> unsigned char offsets_needed;
> unsigned char newline_anchor;
> unsigned char word_ops_used;
> int mb_cur_max;
> };
> typedef struct re_string_t re_string_t;
>
>
> struct re_dfa_t;
> typedef struct re_dfa_t re_dfa_t;
>
>
>
>
>
>
>
>
>
> static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
> Idx new_buf_len)
> ;
>
>
>
>
>
> static void build_upper_buffer (re_string_t *pstr) ;
> static void re_string_translate_buffer (re_string_t *pstr) ;
> static unsigned int re_string_context_at (const re_string_t *input, Idx
idx,
> int eflags)
> ;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 1 "alloca.h" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> # 50 "alloca.h"
>
>
>
> # 472 "regex_internal.h" 2
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> struct bin_tree_t
> {
> struct bin_tree_t *parent;
> struct bin_tree_t *left;
> struct bin_tree_t *right;
> struct bin_tree_t *first;
> struct bin_tree_t *next;
>
> re_token_t token;
>
>
>
> Idx node_idx;
> };
> typedef struct bin_tree_t bin_tree_t;
>
>
>
>
> struct bin_tree_storage_t
> {
> struct bin_tree_storage_t *next;
> bin_tree_t data[((1024 - sizeof (void *)) / sizeof (bin_tree_t)) ];
> };
> typedef struct bin_tree_storage_t bin_tree_storage_t;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> struct re_dfastate_t
> {
> re_hashval_t hash;
> re_node_set nodes;
> re_node_set non_eps_nodes;
> re_node_set inveclosure;
> re_node_set *entrance_nodes;
> struct re_dfastate_t **trtable, **word_trtable;
> unsigned int context : 4;
> unsigned int halt : 1;
>
>
>
> unsigned int accept_mb : 1;
>
> unsigned int has_backref : 1;
> unsigned int has_constraint : 1;
> };
> typedef struct re_dfastate_t re_dfastate_t;
>
> struct re_state_table_entry
> {
> Idx num;
> Idx alloc;
> re_dfastate_t **array;
> };
>
>
>
> typedef struct
> {
> Idx next_idx;
> Idx alloc;
> re_dfastate_t **array;
> } state_array_t;
>
>
>
> typedef struct
> {
> Idx node;
> Idx str_idx;
> state_array_t path;
> } re_sub_match_last_t;
>
>
>
>
>
> typedef struct
> {
> Idx str_idx;
> Idx node;
> state_array_t *path;
> Idx alasts;
> Idx nlasts;
> re_sub_match_last_t **lasts;
> } re_sub_match_top_t;
>
> struct re_backref_cache_entry
> {
> Idx node;
> Idx str_idx;
> Idx subexp_from;
> Idx subexp_to;
> char more;
> char unused;
> unsigned short int eps_reachable_subexps_map;
> };
>
> typedef struct
> {
>
> re_string_t input;
>
>
>
> const re_dfa_t *dfa;
>
>
> int eflags;
>
> Idx match_last;
> Idx last_node;
>
> re_dfastate_t **state_log;
> Idx state_log_top;
>
> Idx nbkref_ents;
> Idx abkref_ents;
> struct re_backref_cache_entry *bkref_ents;
> int max_mb_elem_len;
> Idx nsub_tops;
> Idx asub_tops;
> re_sub_match_top_t **sub_tops;
> } re_match_context_t;
>
> typedef struct
> {
> re_dfastate_t **sifted_states;
> re_dfastate_t **limited_states;
> Idx last_node;
> Idx last_str_idx;
> re_node_set limits;
> } re_sift_context_t;
>
> struct re_fail_stack_ent_t
> {
> Idx idx;
> Idx node;
> regmatch_t *regs;
> re_node_set eps_via_nodes;
> };
>
> struct re_fail_stack_t
> {
> Idx num;
> Idx alloc;
> struct re_fail_stack_ent_t *stack;
> };
>
> struct re_dfa_t
> {
> re_token_t *nodes;
> size_t nodes_alloc;
> size_t nodes_len;
> Idx *nexts;
> Idx *org_indices;
> re_node_set *edests;
> re_node_set *eclosures;
> re_node_set *inveclosures;
> struct re_state_table_entry *state_table;
> re_dfastate_t *init_state;
> re_dfastate_t *init_state_word;
> re_dfastate_t *init_state_nl;
> re_dfastate_t *init_state_begbuf;
> bin_tree_t *str_tree;
> bin_tree_storage_t *str_tree_storage;
> re_bitset_ptr_t sb_char;
> int str_tree_storage_idx;
>
>
> re_hashval_t state_hash_mask;
> Idx init_node;
> Idx nbackref;
>
>
> bitset_word_t used_bkref_map;
> bitset_word_t completed_bkref_map;
>
> unsigned int has_plural_match : 1;
>
>
>
> unsigned int has_mb_node : 1;
> unsigned int is_utf8 : 1;
> unsigned int map_notascii : 1;
> unsigned int word_ops_used : 1;
> int mb_cur_max;
> bitset_t word_char;
> reg_syntax_t syntax;
> Idx *subexp_map;
>
>
>
>
> };
>
>
>
>
>
>
>
>
> typedef enum
> {
> SB_CHAR,
> MB_CHAR,
> EQUIV_CLASS,
> COLL_SYM,
> CHAR_CLASS
> } bracket_elem_type;
>
> typedef struct
> {
> bracket_elem_type type;
> union
> {
> unsigned char ch;
> unsigned char *name;
> wchar_t wch;
> } opr;
> } bracket_elem_t;
>
>
>
>
> static inline void
> bitset_set (bitset_t set, Idx i)
> {
> set[i / 32 ] |= (bitset_word_t) 1 << i % 32 ;
> }
>
> static inline void
> bitset_clear (bitset_t set, Idx i)
> {
> set[i / 32 ] &= ~ ((bitset_word_t) 1 << i % 32 );
> }
>
> static inline _Bool
> bitset_contain (const bitset_t set, Idx i)
> {
> return (set[i / 32 ] >> i % 32 ) & 1;
> }
>
> static inline void
> bitset_empty (bitset_t set)
> {
> memset (set, '\0', sizeof (bitset_t));
> }
>
> static inline void
> bitset_set_all (bitset_t set)
> {
> memset (set, -1, sizeof (bitset_word_t) * ((0xff + 1) / 32 ));
> if ((0xff + 1) % 32 != 0)
> set[(((0xff + 1) + 32 - 1) / 32 ) - 1] =
> ((bitset_word_t) 1 << (0xff + 1) % 32 ) - 1;
> }
>
> static inline void
> bitset_copy (bitset_t dest, const bitset_t src)
> {
> memcpy (dest, src, sizeof (bitset_t));
> }
>
> static inline void
> bitset_not (bitset_t set)
> {
> int bitset_i;
> for (bitset_i = 0; bitset_i < (0xff + 1) / 32 ; ++bitset_i)
> set[bitset_i] = ~set[bitset_i];
> if ((0xff + 1) % 32 != 0)
> set[(((0xff + 1) + 32 - 1) / 32 ) - 1] =
> ((((bitset_word_t) 1 << (0xff + 1) % 32 ) - 1)
> & ~set[(((0xff + 1) + 32 - 1) / 32 ) - 1]);
> }
>
> static inline void
> bitset_merge (bitset_t dest, const bitset_t src)
> {
> int bitset_i;
> for (bitset_i = 0; bitset_i < (((0xff + 1) + 32 - 1) / 32 ) ;
++bitset_i)
> dest[bitset_i] |= src[bitset_i];
> }
>
> static inline void
> bitset_mask (bitset_t dest, const bitset_t src)
> {
> int bitset_i;
> for (bitset_i = 0; bitset_i < (((0xff + 1) + 32 - 1) / 32 ) ;
++bitset_i)
> dest[bitset_i] &= src[bitset_i];
> }
>
> # 864 "regex_internal.h"
>
>
>
> # 60 "regex.c" 2
>
>
> # 1 "regex_internal.c" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> static void re_string_construct_common (const char *str, Idx len,
> re_string_t *pstr,
> unsigned char * trans, _Bool icase,
> const re_dfa_t *dfa) ;
> static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
> const re_node_set *nodes,
> re_hashval_t hash) ;
> static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
> const re_node_set *nodes,
> unsigned int context,
> re_hashval_t hash) ;
>
>
>
>
>
>
> static reg_errcode_t
>
> re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx
init_len,
> unsigned char * trans, _Bool icase, const re_dfa_t *dfa)
> {
> reg_errcode_t ret;
> Idx init_buf_len;
>
>
> if (init_len < dfa->mb_cur_max)
> init_len = dfa->mb_cur_max;
> init_buf_len = (len + 1 < init_len) ? len + 1: init_len;
> re_string_construct_common (str, len, pstr, trans, icase, dfa);
>
> ret = re_string_realloc_buffers (pstr, init_buf_len);
> if (( ret != _REG_NOERROR ) )
> return ret;
>
> pstr->word_char = dfa->word_char;
> pstr->word_ops_used = dfa->word_ops_used;
> pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
> pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len;
> pstr->valid_raw_len = pstr->valid_len;
> return _REG_NOERROR ;
> }
>
>
>
> static reg_errcode_t
>
> re_string_construct (re_string_t *pstr, const char *str, Idx len,
> unsigned char * trans, _Bool icase, const re_dfa_t *dfa)
> {
> reg_errcode_t ret;
> memset (pstr, '\0', sizeof (re_string_t));
> re_string_construct_common (str, len, pstr, trans, icase, dfa);
>
> if (len > 0)
> {
> ret = re_string_realloc_buffers (pstr, len + 1);
> if (( ret != _REG_NOERROR ) )
> return ret;
> }
> pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
>
> if (icase)
> {
> # 102 "regex_internal.c"
>
> build_upper_buffer (pstr);
> }
> else
> {
>
>
>
>
>
> {
> if (trans != 0 )
> re_string_translate_buffer (pstr);
> else
> {
> pstr->valid_len = pstr->bufs_len;
> pstr->valid_raw_len = pstr->bufs_len;
> }
> }
> }
>
> return _REG_NOERROR ;
> }
>
>
>
> static reg_errcode_t
>
> re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
> {
> # 154 "regex_internal.c"
>
> if (pstr->mbs_allocated)
> {
> unsigned char *new_mbs = (( unsigned char *) realloc (
pstr->mbs , (
> new_buf_len ) * sizeof ( unsigned char ))) ;
> if (( new_mbs == 0 ) )
> return _REG_ESPACE ;
> pstr->mbs = new_mbs;
> }
> pstr->bufs_len = new_buf_len;
> return _REG_NOERROR ;
> }
>
>
> static void
>
> re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
> unsigned char * trans, _Bool icase,
> const re_dfa_t *dfa)
> {
> pstr->raw_mbs = (const unsigned char *) str;
> pstr->len = len;
> pstr->raw_len = len;
> pstr->trans = trans;
> pstr->icase = icase;
> pstr->mbs_allocated = (trans != 0 || icase);
> pstr->mb_cur_max = dfa->mb_cur_max;
> pstr->is_utf8 = dfa->is_utf8;
> pstr->map_notascii = dfa->map_notascii;
> pstr->stop = pstr->len;
> pstr->raw_stop = pstr->stop;
> }
>
> # 514 "regex_internal.c"
>
>
>
>
>
> static void
>
> build_upper_buffer (re_string_t *pstr)
> {
> Idx char_idx, end_idx;
> end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
>
> for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
> {
> int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
> if (( pstr->trans != 0 ) )
> ch = pstr->trans[ch];
> if ((!!__maskrune(( ( ch ) ),( 0x00001000L ))) )
> pstr->mbs[char_idx] = __toupper( ch ) ;
> else
> pstr->mbs[char_idx] = ch;
> }
> pstr->valid_len = char_idx;
> pstr->valid_raw_len = char_idx;
> }
>
>
>
> static void
>
> re_string_translate_buffer (re_string_t *pstr)
> {
> Idx buf_idx, end_idx;
> end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
>
> for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx)
> {
> int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx];
> pstr->mbs[buf_idx] = pstr->trans[ch];
> }
>
> pstr->valid_len = buf_idx;
> pstr->valid_raw_len = buf_idx;
> }
>
>
>
>
>
> static reg_errcode_t
>
> re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
> {
> Idx offset;
>
> if (( pstr->raw_mbs_idx <= idx ) )
> offset = idx - pstr->raw_mbs_idx;
> else
> {
>
>
>
>
>
> pstr->len = pstr->raw_len;
> pstr->stop = pstr->raw_stop;
> pstr->valid_len = 0;
> pstr->raw_mbs_idx = 0;
> pstr->valid_raw_len = 0;
> pstr->offsets_needed = 0;
> pstr->tip_context = ((eflags & 1 ) ? ((1 << 1) << 1)
> : (1 << 1) | ((1 << 1) << 1) );
> if (!pstr->mbs_allocated)
> pstr->mbs = (unsigned char *) pstr->raw_mbs;
> offset = idx;
> }
>
> if (( offset != 0 ) )
> {
>
> if (( offset < pstr->valid_raw_len )
>
>
>
>
>
> )
> {
>
> pstr->tip_context = re_string_context_at (pstr, offset - 1, eflags);
>
>
>
>
>
> if (( pstr->mbs_allocated ) )
> memmove (pstr->mbs, pstr->mbs + offset,
> pstr->valid_len - offset);
> pstr->valid_len -= offset;
> pstr->valid_raw_len -= offset;
>
>
>
> }
> else
> {
>
>
>
>
>
>
>
>
>
> pstr->valid_len = 0;
> pstr->valid_raw_len = 0;
> # 709 "regex_internal.c"
>
> {
> int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
> if (pstr->trans)
> c = pstr->trans[c];
> pstr->tip_context = (bitset_contain (pstr->word_char, c)
> ? 1
> : (((( c ) == '\n' ) && pstr->newline_anchor)
> ? (1 << 1) : 0));
> }
> }
> if (! ( pstr->mbs_allocated ) )
> pstr->mbs += offset;
> }
> pstr->raw_mbs_idx = idx;
> pstr->len -= offset;
> pstr->stop -= offset;
>
>
> # 741 "regex_internal.c"
>
> if (( pstr->mbs_allocated ) )
> {
> if (pstr->icase)
> build_upper_buffer (pstr);
> else if (pstr->trans != 0 )
> re_string_translate_buffer (pstr);
> }
> else
> pstr->valid_len = pstr->len;
>
> pstr->cur_idx = 0;
> return _REG_NOERROR ;
> }
>
> static unsigned char
>
> re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
> {
> int ch;
> Idx off;
>
>
> if (( !pstr->mbs_allocated ) )
> return (( pstr )->mbs[( pstr )->cur_idx + idx ]) ;
>
>
>
>
>
>
>
> off = pstr->cur_idx + idx;
>
>
>
>
>
> ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
>
>
>
>
>
>
>
>
>
>
> return ch;
> }
>
> static unsigned char
>
> re_string_fetch_byte_case (re_string_t *pstr)
> {
> if (( !pstr->mbs_allocated ) )
> return (( pstr )->mbs[( pstr )->cur_idx++]) ;
>
> # 826 "regex_internal.c"
>
>
> return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
> }
>
> static void
>
> re_string_destruct (re_string_t *pstr)
> {
>
>
>
>
> if (pstr->mbs_allocated)
> free ( pstr->mbs ) ;
> }
>
>
>
> static unsigned int
>
> re_string_context_at (const re_string_t *input, Idx idx, int eflags)
> {
> int c;
> if (( ! ((Idx) ( idx ) < ((Idx) -2) ) ) )
>
>
> return input->tip_context;
> if (( idx == input->len ) )
> return ((eflags & (1 << 1) ) ? (((1 << 1) << 1) << 1)
> : (1 << 1) | (((1 << 1) << 1) << 1) );
> # 879 "regex_internal.c"
>
> {
> c = (( input )->mbs[ idx ]) ;
> if (bitset_contain (input->word_char, c))
> return 1 ;
> return (( c ) == '\n' ) && input->newline_anchor ? (1 << 1) : 0;
> }
> }
>
>
>
> static reg_errcode_t
>
> re_node_set_alloc (re_node_set *set, Idx size)
> {
> set->alloc = size;
> set->nelem = 0;
> set->elems = (( Idx *) malloc (( size ) * sizeof ( Idx ))) ;
> if (( set->elems == 0 ) )
> return _REG_ESPACE ;
> return _REG_NOERROR ;
> }
>
> static reg_errcode_t
>
> re_node_set_init_1 (re_node_set *set, Idx elem)
> {
> set->alloc = 1;
> set->nelem = 1;
> set->elems = (( Idx *) malloc (( 1 ) * sizeof ( Idx ))) ;
> if (( set->elems == 0 ) )
> {
> set->alloc = set->nelem = 0;
> return _REG_ESPACE ;
> }
> set->elems[0] = elem;
> return _REG_NOERROR ;
> }
>
> static reg_errcode_t
>
> re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
> {
> set->alloc = 2;
> set->elems = (( Idx *) malloc (( 2 ) * sizeof ( Idx ))) ;
> if (( set->elems == 0 ) )
> return _REG_ESPACE ;
> if (elem1 == elem2)
> {
> set->nelem = 1;
> set->elems[0] = elem1;
> }
> else
> {
> set->nelem = 2;
> if (elem1 < elem2)
> {
> set->elems[0] = elem1;
> set->elems[1] = elem2;
> }
> else
> {
> set->elems[0] = elem2;
> set->elems[1] = elem1;
> }
> }
> return _REG_NOERROR ;
> }
>
> static reg_errcode_t
>
> re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
> {
> dest->nelem = src->nelem;
> if (src->nelem > 0)
> {
> dest->alloc = dest->nelem;
> dest->elems = (( Idx *) malloc (( dest->alloc ) * sizeof ( Idx
))) ;
> if (( dest->elems == 0 ) )
> {
> dest->alloc = dest->nelem = 0;
> return _REG_ESPACE ;
> }
> memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
> }
> else
> memset ( dest , '\0', sizeof (re_node_set)) ;
> return _REG_NOERROR ;
> }
>
>
>
>
>
> static reg_errcode_t
>
> re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
> const re_node_set *src2)
> {
> Idx i1, i2, is, id, delta, sbase;
> if (src1->nelem == 0 || src2->nelem == 0)
> return _REG_NOERROR ;
>
>
>
> if (src1->nelem + src2->nelem + dest->nelem > dest->alloc)
> {
> Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
> Idx *new_elems = (( Idx *) realloc ( dest->elems , ( new_alloc
) * sizeof ( Idx ))) ;
> if (( new_elems == 0 ) )
> return _REG_ESPACE ;
> dest->elems = new_elems;
> dest->alloc = new_alloc;
> }
>
>
>
> sbase = dest->nelem + src1->nelem + src2->nelem;
> i1 = src1->nelem - 1;
> i2 = src2->nelem - 1;
> id = dest->nelem - 1;
> for (;;)
> {
> if (src1->elems[i1] == src2->elems[i2])
> {
>
> while (((Idx) ( id ) < ((Idx) -2) ) && dest->elems[id] >
src1->elems[i1])
> --id;
>
> if (! ((Idx) ( id ) < ((Idx) -2) ) || dest->elems[id] !=
src1->elems[i1])
> dest->elems[--sbase] = src1->elems[i1];
>
> if (! ((Idx) ( --i1 ) < ((Idx) -2) ) || ! ((Idx) ( --i2 ) <
((Idx) -2) ) )
> break;
> }
>
>
> else if (src1->elems[i1] < src2->elems[i2])
> {
> if (! ((Idx) ( --i2 ) < ((Idx) -2) ) )
> break;
> }
> else
> {
> if (! ((Idx) ( --i1 ) < ((Idx) -2) ) )
> break;
> }
> }
>
> id = dest->nelem - 1;
> is = dest->nelem + src1->nelem + src2->nelem - 1;
> delta = is - sbase + 1;
>
>
>
>
> dest->nelem += delta;
> if (delta > 0 && ((Idx) ( id ) < ((Idx) -2) ) )
> for (;;)
> {
> if (dest->elems[is] > dest->elems[id])
> {
>
> dest->elems[id + delta--] = dest->elems[is--];
> if (delta == 0)
> break;
> }
> else
> {
>
> dest->elems[id + delta] = dest->elems[id];
> if (! ((Idx) ( --id ) < ((Idx) -2) ) )
> break;
> }
> }
>
>
> memcpy (dest->elems, dest->elems + sbase, delta * sizeof (Idx));
>
> return _REG_NOERROR ;
> }
>
>
>
>
> static reg_errcode_t
>
> re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
> const re_node_set *src2)
> {
> Idx i1, i2, id;
> if (src1 != 0 && src1->nelem > 0 && src2 != 0 && src2->nelem > 0)
> {
> dest->alloc = src1->nelem + src2->nelem;
> dest->elems = (( Idx *) malloc (( dest->alloc ) * sizeof ( Idx
))) ;
> if (( dest->elems == 0 ) )
> return _REG_ESPACE ;
> }
> else
> {
> if (src1 != 0 && src1->nelem > 0)
> return re_node_set_init_copy (dest, src1);
> else if (src2 != 0 && src2->nelem > 0)
> return re_node_set_init_copy (dest, src2);
> else
> memset ( dest , '\0', sizeof (re_node_set)) ;
> return _REG_NOERROR ;
> }
> for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
> {
> if (src1->elems[i1] > src2->elems[i2])
> {
> dest->elems[id++] = src2->elems[i2++];
> continue;
> }
> if (src1->elems[i1] == src2->elems[i2])
> ++i2;
> dest->elems[id++] = src1->elems[i1++];
> }
> if (i1 < src1->nelem)
> {
> memcpy (dest->elems + id, src1->elems + i1,
> (src1->nelem - i1) * sizeof (Idx));
> id += src1->nelem - i1;
> }
> else if (i2 < src2->nelem)
> {
> memcpy (dest->elems + id, src2->elems + i2,
> (src2->nelem - i2) * sizeof (Idx));
> id += src2->nelem - i2;
> }
> dest->nelem = id;
> return _REG_NOERROR ;
> }
>
>
>
>
> static reg_errcode_t
>
> re_node_set_merge (re_node_set *dest, const re_node_set *src)
> {
> Idx is, id, sbase, delta;
> if (src == 0 || src->nelem == 0)
> return _REG_NOERROR ;
> if (dest->alloc < 2 * src->nelem + dest->nelem)
> {
> Idx new_alloc = 2 * (src->nelem + dest->alloc);
> Idx *new_buffer = (( Idx *) realloc ( dest->elems , (
new_alloc ) * sizeof ( Idx ))) ;
> if (( new_buffer == 0 ) )
> return _REG_ESPACE ;
> dest->elems = new_buffer;
> dest->alloc = new_alloc;
> }
>
> if (( dest->nelem == 0 ) )
> {
> dest->nelem = src->nelem;
> memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
> return _REG_NOERROR ;
> }
>
>
>
> for (sbase = dest->nelem + 2 * src->nelem,
> is = src->nelem - 1, id = dest->nelem - 1;
> ((Idx) ( is ) < ((Idx) -2) ) && ((Idx) ( id ) < ((Idx) -2) ) ; )
> {
> if (dest->elems[id] == src->elems[is])
> is--, id--;
> else if (dest->elems[id] < src->elems[is])
> dest->elems[--sbase] = src->elems[is--];
> else
> --id;
> }
>
> if (((Idx) ( is ) < ((Idx) -2) ) )
> {
>
> sbase -= is + 1;
> memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (Idx));
> }
>
> id = dest->nelem - 1;
> is = dest->nelem + 2 * src->nelem - 1;
> delta = is - sbase + 1;
> if (delta == 0)
> return _REG_NOERROR ;
>
>
>
> dest->nelem += delta;
> for (;;)
> {
> if (dest->elems[is] > dest->elems[id])
> {
>
> dest->elems[id + delta--] = dest->elems[is--];
> if (delta == 0)
> break;
> }
> else
> {
>
> dest->elems[id + delta] = dest->elems[id];
> if (! ((Idx) ( --id ) < ((Idx) -2) ) )
> {
>
> memcpy (dest->elems, dest->elems + sbase,
> delta * sizeof (Idx));
> break;
> }
> }
> }
>
> return _REG_NOERROR ;
> }
>
>
>
>
>
> static _Bool
>
> re_node_set_insert (re_node_set *set, Idx elem)
> {
> Idx idx;
>
> if (set->alloc == 0)
> return ( re_node_set_init_1 (set, elem) == _REG_NOERROR ) ;
>
> if (( set->nelem ) == 0)
> {
>
> set->elems[0] = elem;
> ++set->nelem;
> return 1 ;
> }
>
>
> if (set->alloc == set->nelem)
> {
> Idx *new_elems;
> set->alloc = set->alloc * 2;
> new_elems = (( Idx *) realloc ( set->elems , ( set->alloc ) *
sizeof ( Idx ))) ;
> if (( new_elems == 0 ) )
> return 0 ;
> set->elems = new_elems;
> }
>
>
>
> if (elem < set->elems[0])
> {
> idx = 0;
> for (idx = set->nelem; idx > 0; idx--)
> set->elems[idx] = set->elems[idx - 1];
> }
> else
> {
> for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
> set->elems[idx] = set->elems[idx - 1];
> }
>
>
> set->elems[idx] = elem;
> ++set->nelem;
> return 1 ;
> }
>
>
>
>
>
> static _Bool
>
> re_node_set_insert_last (re_node_set *set, Idx elem)
> {
>
> if (set->alloc == set->nelem)
> {
> Idx *new_elems;
> set->alloc = (set->alloc + 1) * 2;
> new_elems = (( Idx *) realloc ( set->elems , ( set->alloc ) *
sizeof ( Idx ))) ;
> if (( new_elems == 0 ) )
> return 0 ;
> set->elems = new_elems;
> }
>
>
> set->elems[set->nelem++] = elem;
> return 1 ;
> }
>
>
>
>
> static _Bool
>
> re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
> {
> Idx i;
> if (set1 == 0 || set2 == 0 || set1->nelem != set2->nelem)
> return 0 ;
> for (i = set1->nelem ; ((Idx) ( --i ) < ((Idx) -2) ) ; )
> if (set1->elems[i] != set2->elems[i])
> return 0 ;
> return 1 ;
> }
>
>
>
> static Idx
>
> re_node_set_contains (const re_node_set *set, Idx elem)
> {
> __re_size_t idx, right, mid;
> if (! ((Idx) (( set->nelem ) - 1) < (Idx) (((Idx) -2) - 1)) )
> return 0;
>
>
> idx = 0;
> right = set->nelem - 1;
> while (idx < right)
> {
> mid = (idx + right) / 2;
> if (set->elems[mid] < elem)
> idx = mid + 1;
> else
> right = mid;
> }
> return set->elems[idx] == elem ? idx + 1 : 0;
> }
>
> static void
>
> re_node_set_remove_at (re_node_set *set, Idx idx)
> {
> if (idx < 0 || idx >= set->nelem)
> return;
> --set->nelem;
> for (; idx < set->nelem; idx++)
> set->elems[idx] = set->elems[idx + 1];
> }
>
>
>
>
>
> static Idx
>
> re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
> {
> int type = token.type;
> if (( dfa->nodes_len >= dfa->nodes_alloc ) )
> {
> size_t new_nodes_alloc = dfa->nodes_alloc * 2;
> Idx *new_nexts, *new_indices;
> re_node_set *new_edests, *new_eclosures;
> re_token_t *new_nodes;
> size_t max_object_size =
> (( sizeof (re_token_t) ) < (
> (( sizeof (re_node_set) ) < (
> sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(re_node_set) )) ) ? ( (( sizeof (re_node_set) ) <
( sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(re_node_set) )) ) : ( sizeof (re_token_t) )) ;
>
>
> if (( 4294967295U / 2 / max_object_size < dfa->nodes_alloc ) )
> return ((Idx) -1) ;
>
> new_nodes = (( re_token_t *) realloc ( dfa->nodes , (
new_nodes_alloc ) * sizeof ( re_token_t ))) ;
> if (( new_nodes == 0 ) )
> return ((Idx) -1) ;
> dfa->nodes = new_nodes;
> new_nexts = (( Idx *) realloc ( dfa->nexts , ( new_nodes_alloc
) * sizeof ( Idx ))) ;
> new_indices = (( Idx *) realloc ( dfa->org_indices , (
new_nodes_alloc ) * sizeof ( Idx ))) ;
> new_edests = (( re_node_set *) realloc ( dfa->edests , (
new_nodes_alloc ) * sizeof ( re_node_set ))) ;
> new_eclosures = (( re_node_set *) realloc ( dfa->eclosures , (
new_nodes_alloc ) * sizeof ( re_node_set ))) ;
> if (( new_nexts == 0 || new_indices == 0
> || new_edests == 0 || new_eclosures == 0 ) )
> return ((Idx) -1) ;
> dfa->nexts = new_nexts;
> dfa->org_indices = new_indices;
> dfa->edests = new_edests;
> dfa->eclosures = new_eclosures;
> dfa->nodes_alloc = new_nodes_alloc;
> }
> dfa->nodes[dfa->nodes_len] = token;
> dfa->nodes[dfa->nodes_len].constraint = 0;
>
>
>
>
> dfa->nexts[dfa->nodes_len] = ((Idx) -1) ;
> memset ( dfa->edests + dfa->nodes_len , '\0', sizeof (re_node_set)) ;
> memset ( dfa->eclosures + dfa->nodes_len , '\0', sizeof (re_node_set)) ;
> return dfa->nodes_len++;
> }
>
> static inline re_hashval_t
>
> calc_state_hash (const re_node_set *nodes, unsigned int context)
> {
> re_hashval_t hash = nodes->nelem + context;
> Idx i;
> for (i = 0 ; i < nodes->nelem ; i++)
> hash += nodes->elems[i];
> return hash;
> }
>
>
>
>
>
>
>
>
>
>
> static re_dfastate_t *
>
> re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
> const re_node_set *nodes)
> {
> re_hashval_t hash;
> re_dfastate_t *new_state;
> struct re_state_table_entry *spot;
> Idx i;
>
>
>
>
> if (( nodes->nelem == 0 ) )
> {
> *err = _REG_NOERROR ;
> return 0 ;
> }
> hash = calc_state_hash (nodes, 0);
> spot = dfa->state_table + (hash & dfa->state_hash_mask);
>
> for (i = 0 ; i < spot->num ; i++)
> {
> re_dfastate_t *state = spot->array[i];
> if (hash != state->hash)
> continue;
> if (re_node_set_compare (&state->nodes, nodes))
> return state;
> }
>
>
> new_state = create_ci_newstate (dfa, nodes, hash);
> if (( new_state == 0 ) )
> *err = _REG_ESPACE ;
>
> return new_state;
> }
>
>
>
>
>
>
>
>
>
>
>
> static re_dfastate_t *
>
> re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
> const re_node_set *nodes, unsigned int context)
> {
> re_hashval_t hash;
> re_dfastate_t *new_state;
> struct re_state_table_entry *spot;
> Idx i;
>
>
>
>
> if (nodes->nelem == 0)
> {
> *err = _REG_NOERROR ;
> return 0 ;
> }
> hash = calc_state_hash (nodes, context);
> spot = dfa->state_table + (hash & dfa->state_hash_mask);
>
> for (i = 0 ; i < spot->num ; i++)
> {
> re_dfastate_t *state = spot->array[i];
> if (state->hash == hash
> && state->context == context
> && re_node_set_compare (state->entrance_nodes, nodes))
> return state;
> }
>
> new_state = create_cd_newstate (dfa, nodes, context, hash);
> if (( new_state == 0 ) )
> *err = _REG_ESPACE ;
>
> return new_state;
> }
>
>
>
>
>
> static reg_errcode_t
> register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
> re_hashval_t hash)
> {
> struct re_state_table_entry *spot;
> reg_errcode_t err;
> Idx i;
>
> newstate->hash = hash;
> err = re_node_set_alloc (&newstate->non_eps_nodes,
newstate->nodes.nelem);
> if (( err != _REG_NOERROR ) )
> return _REG_ESPACE ;
> for (i = 0; i < newstate->nodes.nelem; i++)
> {
> Idx elem = newstate->nodes.elems[i];
> if (! (( dfa->nodes[elem].type ) & 8 ) )
> if (( ! re_node_set_insert_last (&newstate->non_eps_nodes, elem) ) )
> return _REG_ESPACE ;
> }
>
> spot = dfa->state_table + (hash & dfa->state_hash_mask);
> if (( spot->alloc <= spot->num ) )
> {
> Idx new_alloc = 2 * spot->num + 2;
> re_dfastate_t **new_array = (( re_dfastate_t * *) realloc (
spot->array , (
> new_alloc ) * sizeof ( re_dfastate_t * ))) ;
> if (( new_array == 0 ) )
> return _REG_ESPACE ;
> spot->array = new_array;
> spot->alloc = new_alloc;
> }
> spot->array[spot->num++] = newstate;
> return _REG_NOERROR ;
> }
>
> static void
> free_state (re_dfastate_t *state)
> {
> free ( ( &state->non_eps_nodes )->elems ) ;
> free ( ( &state->inveclosure )->elems ) ;
> if (state->entrance_nodes != &state->nodes)
> {
> free ( ( state->entrance_nodes )->elems ) ;
> free ( state->entrance_nodes ) ;
> }
> free ( ( &state->nodes )->elems ) ;
> free ( state->word_trtable ) ;
> free ( state->trtable ) ;
> free ( state ) ;
> }
>
>
>
>
> static re_dfastate_t *
>
> create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
> re_hashval_t hash)
> {
> Idx i;
> reg_errcode_t err;
> re_dfastate_t *newstate;
>
> newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
> if (( newstate == 0 ) )
> return 0 ;
> err = re_node_set_init_copy (&newstate->nodes, nodes);
> if (( err != _REG_NOERROR ) )
> {
> free ( newstate ) ;
> return 0 ;
> }
>
> newstate->entrance_nodes = &newstate->nodes;
> for (i = 0 ; i < nodes->nelem ; i++)
> {
> re_token_t *node = dfa->nodes + nodes->elems[i];
> re_token_type_t type = node->type;
> if (type == CHARACTER && !node->constraint)
> continue;
>
>
>
>
>
> if (type == END_OF_RE)
> newstate->halt = 1;
> else if (type == OP_BACK_REF)
> newstate->has_backref = 1;
> else if (type == ANCHOR || node->constraint)
> newstate->has_constraint = 1;
> }
> err = register_state (dfa, newstate, hash);
> if (( err != _REG_NOERROR ) )
> {
> free_state (newstate);
> newstate = 0 ;
> }
> return newstate;
> }
>
>
>
>
> static re_dfastate_t *
>
> create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
> unsigned int context, re_hashval_t hash)
> {
> Idx i, nctx_nodes = 0;
> reg_errcode_t err;
> re_dfastate_t *newstate;
>
> newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
> if (( newstate == 0 ) )
> return 0 ;
> err = re_node_set_init_copy (&newstate->nodes, nodes);
> if (( err != _REG_NOERROR ) )
> {
> free ( newstate ) ;
> return 0 ;
> }
>
> newstate->context = context;
> newstate->entrance_nodes = &newstate->nodes;
>
> for (i = 0 ; i < nodes->nelem ; i++)
> {
> unsigned int constraint = 0;
> re_token_t *node = dfa->nodes + nodes->elems[i];
> re_token_type_t type = node->type;
> if (node->constraint)
> constraint = node->constraint;
>
> if (type == CHARACTER && !constraint)
> continue;
>
>
>
>
>
> if (type == END_OF_RE)
> newstate->halt = 1;
> else if (type == OP_BACK_REF)
> newstate->has_backref = 1;
> else if (type == ANCHOR)
> constraint = node->opr.ctx_type;
>
> if (constraint)
> {
> if (newstate->entrance_nodes == &newstate->nodes)
> {
> newstate->entrance_nodes = (( re_node_set *) malloc (( 1 )
* sizeof ( re_node_set ))) ;
> if (( newstate->entrance_nodes == 0 ) )
> {
> free_state (newstate);
> return 0 ;
> }
> re_node_set_init_copy (newstate->entrance_nodes, nodes);
> nctx_nodes = 0;
> newstate->has_constraint = 1;
> }
>
> if ((((( constraint ) & 0x0001 ) && ! (( context ) & 1 ) ) ||
(( constraint & 0x0002 ) && (( context ) & 1 ) ) || (( constraint &
0x0010 ) && ! (( context ) & (1 << 1) ) ) || (( constraint & 0x0040
) && ! (( context ) & ((1 << 1) << 1) ) )) )
> {
> re_node_set_remove_at (&newstate->nodes, i - nctx_nodes);
> ++nctx_nodes;
> }
> }
> }
> err = register_state (dfa, newstate, hash);
> if (( err != _REG_NOERROR ) )
> {
> free_state (newstate);
> newstate = 0 ;
> }
> return newstate;
> }
> # 62 "regex.c" 2
>
> # 1 "regcomp.c" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> static reg_errcode_t re_compile_internal (regex_t *preg, const char *
pattern,
> size_t length, reg_syntax_t syntax);
> static void re_compile_fastmap_iter (regex_t *bufp,
> const re_dfastate_t *init_state,
> char *fastmap);
> static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
>
>
>
> static void free_workarea_compile (regex_t *preg);
> static reg_errcode_t create_initial_state (re_dfa_t *dfa);
>
>
>
> static reg_errcode_t analyze (regex_t *preg);
> static reg_errcode_t preorder (bin_tree_t *root,
> reg_errcode_t (fn (void *, bin_tree_t *)),
> void *extra);
> static reg_errcode_t postorder (bin_tree_t *root,
> reg_errcode_t (fn (void *, bin_tree_t *)),
> void *extra);
> static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node);
> static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node);
> static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg,
> bin_tree_t *node);
> static reg_errcode_t calc_first (void *extra, bin_tree_t *node);
> static reg_errcode_t calc_next (void *extra, bin_tree_t *node);
> static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node);
> static Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int
constraint);
> static Idx search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
> unsigned int constraint);
> static reg_errcode_t calc_eclosure (re_dfa_t *dfa);
> static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t
*dfa,
> Idx node, _Bool root);
> static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
> static Idx fetch_number (re_string_t *input, re_token_t *token,
> reg_syntax_t syntax);
> static int peek_token (re_token_t *token, re_string_t *input,
> reg_syntax_t syntax) ;
> static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
> reg_syntax_t syntax, reg_errcode_t *err);
> static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
> re_token_t *token, reg_syntax_t syntax,
> Idx nest, reg_errcode_t *err);
> static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg,
> re_token_t *token, reg_syntax_t syntax,
> Idx nest, reg_errcode_t *err);
> static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg,
> re_token_t *token, reg_syntax_t syntax,
> Idx nest, reg_errcode_t *err);
> static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg,
> re_token_t *token, reg_syntax_t syntax,
> Idx nest, reg_errcode_t *err);
> static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp,
> re_dfa_t *dfa, re_token_t *token,
> reg_syntax_t syntax, reg_errcode_t *err);
> static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa,
> re_token_t *token, reg_syntax_t syntax,
> reg_errcode_t *err);
> static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
> re_string_t *regexp,
> re_token_t *token, int token_len,
> re_dfa_t *dfa,
> reg_syntax_t syntax,
> _Bool accept_hyphen);
> static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
> re_string_t *regexp,
> re_token_t *token);
> # 99 "regcomp.c"
>
> static reg_errcode_t build_equiv_class (bitset_t sbcset,
> const unsigned char *name);
> static reg_errcode_t build_charclass (unsigned char * trans,
> bitset_t sbcset,
> const unsigned char *class_name,
> reg_syntax_t syntax);
>
> static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
> unsigned char * trans,
> const unsigned char *class_name,
> const unsigned char *extra,
> _Bool non_match, reg_errcode_t *err);
> static bin_tree_t *create_tree (re_dfa_t *dfa,
> bin_tree_t *left, bin_tree_t *right,
> re_token_type_t type);
> static bin_tree_t *create_token_tree (re_dfa_t *dfa,
> bin_tree_t *left, bin_tree_t *right,
> const re_token_t *token);
> static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa);
> static void free_token (re_token_t *node);
> static reg_errcode_t free_tree (void *extra, bin_tree_t *node);
> static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node);
>
>
>
>
>
>
> static const char __re_error_msgid[] =
> {
>
> "Success"
> "\0"
>
> "No match"
> "\0"
>
> "Invalid regular expression"
> "\0"
>
> "Invalid collation character"
> "\0"
>
> "Invalid character class name"
> "\0"
>
> "Trailing backslash"
> "\0"
>
> "Invalid back reference"
> "\0"
>
> "Unmatched [ or [^"
> "\0"
>
> "Unmatched ( or \\("
> "\0"
>
> "Unmatched \\{"
> "\0"
>
> "Invalid content of \\{\\}"
> "\0"
>
> "Invalid range end"
> "\0"
>
> "Memory exhausted"
> "\0"
>
> "Invalid preceding regular expression"
> "\0"
>
> "Premature end of regular expression"
> "\0"
>
> "Regular expression too big"
> "\0"
>
> "Unmatched ) or \\)"
> };
>
> static const size_t __re_error_msgid_idx[] =
> {
> 0 ,
> (0 + sizeof "Success") ,
> ((0 + sizeof "Success") + sizeof "No match") ,
> (((0 + sizeof "Success") + sizeof "No match") + sizeof "Invalid
regular expression") ,
> ((((0 + sizeof "Success") + sizeof "No match") + sizeof "Invalid
regular expression") + sizeof "Invalid collation character") ,
> (((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") ,
> ((((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") + sizeof "Trailing backslash") ,
> (((((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") + sizeof "Trailing
backslash") + sizeof "Invalid back reference") ,
> ((((((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") + sizeof "Trailing
backslash") + sizeof "Invalid back reference") + sizeof "Unmatched [
or [^") ,
> (((((((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") + sizeof "Trailing
backslash") + sizeof "Invalid back reference") + sizeof "Unmatched [
or [^") + sizeof "Unmatched ( or \\(") ,
> ((((((((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") + sizeof "Trailing
backslash") + sizeof "Invalid back reference") + sizeof "Unmatched [
or [^") + sizeof "Unmatched ( or \\(") + sizeof "Unmatched \\{") ,
> (((((((((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") + sizeof "Trailing
backslash") + sizeof "Invalid back reference") + sizeof "Unmatched [
or [^") + sizeof "Unmatched ( or \\(") + sizeof "Unmatched \\{") +
sizeof "Invalid content of \\{\\}") ,
> ((((((((((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") + sizeof "Trailing
backslash") + sizeof "Invalid back reference") + sizeof "Unmatched [
or [^") + sizeof "Unmatched ( or \\(") + sizeof "Unmatched \\{") +
sizeof "Invalid content of \\{\\}") + sizeof "Invalid range end") ,
> (((((((((((((0 + sizeof "Success") + sizeof "No match") + sizeof
"Invalid regular expression") + sizeof "Invalid collation character")
+ sizeof "Invalid character class name") + sizeof "Trailing
backslash") + sizeof "Invalid back reference") + sizeof "Unmatched [
or [^") + sizeof "Unmatched ( or \\(") + sizeof "Unmatched \\{") +
sizeof "Invalid content of \\{\\}") + sizeof "Invalid range end") +
sizeof "Memory exhausted") ,
> ((((((((((((((0 + sizeof "Success") + sizeof "No match") +
sizeof "Invalid regular expression") + sizeof "Invalid collation
character") + sizeof "Invalid character class name") + sizeof
"Trailing backslash") + sizeof "Invalid back reference") + sizeof
"Unmatched [ or [^") + sizeof "Unmatched ( or \\(") + sizeof
"Unmatched \\{") + sizeof "Invalid content of \\{\\}") + sizeof
"Invalid range end") + sizeof "Memory exhausted") + sizeof "Invalid
preceding regular expression") ,
> (((((((((((((((0 + sizeof "Success") + sizeof "No match") +
sizeof "Invalid regular expression") + sizeof "Invalid collation
character") + sizeof "Invalid character class name") + sizeof
"Trailing backslash") + sizeof "Invalid back reference") + sizeof
"Unmatched [ or [^") + sizeof "Unmatched ( or \\(") + sizeof
"Unmatched \\{") + sizeof "Invalid content of \\{\\}") + sizeof
"Invalid range end") + sizeof "Memory exhausted") + sizeof "Invalid
preceding regular expression") + sizeof "Premature end of regular
expression") ,
> ((((((((((((((((0 + sizeof "Success") + sizeof "No match") +
sizeof "Invalid regular expression") + sizeof "Invalid collation
character") + sizeof "Invalid character class name") + sizeof
"Trailing backslash") + sizeof "Invalid back reference") + sizeof
"Unmatched [ or [^") + sizeof "Unmatched ( or \\(") + sizeof
"Unmatched \\{") + sizeof "Invalid content of \\{\\}") + sizeof
"Invalid range end") + sizeof "Memory exhausted") + sizeof "Invalid
preceding regular expression") + sizeof "Premature end of regular
expression") + sizeof "Regular expression too big")
> };
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> const char *
> rpl_re_compile_pattern (const char *pattern, size_t length,
> struct re_pattern_buffer *bufp)
>
> {
> reg_errcode_t ret;
>
>
>
>
> bufp->no_sub = !!(rpl_re_syntax_options &
(((((((((((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) );
>
>
> bufp->newline_anchor = 1;
>
> ret = re_compile_internal (bufp, pattern, length,
rpl_re_syntax_options );
>
> if (!ret)
> return 0 ;
> return ( __re_error_msgid + __re_error_msgid_idx[(int) ret] ) ;
> }
>
>
>
>
>
>
>
>
>
> reg_syntax_t rpl_re_syntax_options ;
>
>
>
>
>
>
>
>
>
> reg_syntax_t
> rpl_re_set_syntax (syntax)
> reg_syntax_t syntax;
> {
> reg_syntax_t ret = rpl_re_syntax_options ;
>
> rpl_re_syntax_options = syntax;
> return ret;
> }
>
>
>
>
> int
> rpl_re_compile_fastmap (bufp)
> struct re_pattern_buffer *bufp;
> {
> re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
> char *fastmap = bufp->fastmap;
>
> memset (fastmap, '\0', sizeof (char) * (0xff + 1) );
> re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
> if (dfa->init_state != dfa->init_state_word)
> re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap);
> if (dfa->init_state != dfa->init_state_nl)
> re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
> if (dfa->init_state != dfa->init_state_begbuf)
> re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
> bufp->fastmap_accurate = 1;
> return 0;
> }
>
>
>
>
> static inline void
>
> re_set_fastmap (char *fastmap, _Bool icase, int ch)
> {
> fastmap[ch] = 1;
> if (icase)
> fastmap[__tolower( ch ) ] = 1;
> }
>
>
>
>
> static void
> re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
> char *fastmap)
> {
> re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
> Idx node_cnt;
> _Bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax &
((((((((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ));
> for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
> {
> Idx node = init_state->nodes.elems[node_cnt];
> re_token_type_t type = dfa->nodes[node].type;
>
> if (type == CHARACTER)
> {
> re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
> # 342 "regcomp.c"
>
> }
> else if (type == SIMPLE_BRACKET)
> {
> int i, ch;
> for (i = 0, ch = 0; i < (((0xff + 1) + 32 - 1) / 32 ) ; ++i)
> {
> int j;
> bitset_word_t w = dfa->nodes[node].opr.sbcset[i];
> for (j = 0; j < 32 ; ++j, ++ch)
> if (w & ((bitset_word_t) 1 << j))
> re_set_fastmap (fastmap, icase, ch);
> }
> }
> # 401 "regcomp.c"
>
> else if (type == OP_PERIOD
>
>
>
> || type == END_OF_RE)
> {
> memset (fastmap, '\1', sizeof (char) * (0xff + 1) );
> if (type == END_OF_RE)
> bufp->can_be_null = 1;
> return;
> }
> }
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> int
> rpl_regcomp (preg, pattern, cflags)
> regex_t *__restrict preg;
> const char *__restrict pattern;
> int cflags;
> {
> reg_errcode_t ret;
> reg_syntax_t syntax = ((cflags & 1 ) ? ((((((unsigned long int) 1)
<< 1) << 1) | ((((((((unsigned long int) 1) << 1) << 1) << 1) <<
1) << 1) << 1) | (((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) | (((((((((((unsigned long int)
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) |
((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) ) | (((((unsigned long int) 1) << 1) << 1) << 1) |
((((((unsigned long int) 1) << 1) << 1) << 1) << 1) |
((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) |
(((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) |
(((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) !
> << 1) << 1) << 1) << 1) << 1) | (((((((unsigned long int) 1)
<< 1) << 1) << 1) << 1) << 1) | (((((((((((((((((((unsigned long
int) 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) )
> : ((((((unsigned long int) 1) << 1) << 1) |
((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) << 1) <<
1) | (((((((((unsigned long int) 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) | (((((((((((unsigned long int) 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) |
((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) ) | (((unsigned long int) 1) << 1) |
((((((((((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1)
) );
>
> preg->buffer = 0 ;
> preg->allocated = 0;
> preg->used = 0;
>
>
> preg->fastmap = (( char *) malloc (( (0xff + 1) ) * sizeof ( char
))) ;
> if (( preg->fastmap == 0 ) )
> return _REG_ESPACE ;
>
> syntax |= (cflags & (1 << 1) ) ? ((((((((((((((((((((((((unsigned
long int) 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) : 0;
>
>
> if (cflags & (1 << 2) )
> {
> syntax &= ~((((((((unsigned long int) 1) << 1) << 1) << 1) <<
1) << 1) << 1) ;
> syntax |= ((((((((((unsigned long int) 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) ;
>
> preg->newline_anchor = 1;
> }
> else
> preg->newline_anchor = 0;
> preg->no_sub = !!(cflags & (1 << 3) );
> preg->translate = 0 ;
>
> ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);
>
>
>
> if (ret == _REG_ERPAREN )
> ret = _REG_EPAREN ;
>
>
> if (( ret == _REG_NOERROR ) )
>
>
> (void) rpl_re_compile_fastmap (preg);
> else
> {
>
> free ( preg->fastmap ) ;
> preg->fastmap = 0 ;
> }
>
> return (int) ret;
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> size_t
> rpl_regerror (int errcode, const regex_t *__restrict preg,
> char *__restrict errbuf, size_t errbuf_size)
>
> {
> const char *msg;
> size_t msg_size;
>
> if (( errcode < 0
> || errcode >= (int) (sizeof (__re_error_msgid_idx)
> / sizeof (__re_error_msgid_idx[0])) ) )
>
>
>
>
> abort ();
>
> msg = ( __re_error_msgid + __re_error_msgid_idx[errcode] ) ;
>
> msg_size = strlen (msg) + 1;
>
> if (( errbuf_size != 0 ) )
> {
> if (( msg_size > errbuf_size ) )
> {
>
>
>
> memcpy (errbuf, msg, errbuf_size - 1);
> errbuf[errbuf_size - 1] = 0;
>
> }
> else
> memcpy (errbuf, msg, msg_size);
> }
>
> return msg_size;
> }
>
>
>
>
>
> # 587 "regcomp.c"
>
>
>
> static void
> free_dfa_content (re_dfa_t *dfa)
> {
> Idx i, j;
>
> if (dfa->nodes)
> for (i = 0; i < dfa->nodes_len; ++i)
> free_token (dfa->nodes + i);
> free ( dfa->nexts ) ;
> for (i = 0; i < dfa->nodes_len; ++i)
> {
> if (dfa->eclosures != 0 )
> free ( ( dfa->eclosures + i )->elems ) ;
> if (dfa->inveclosures != 0 )
> free ( ( dfa->inveclosures + i )->elems ) ;
> if (dfa->edests != 0 )
> free ( ( dfa->edests + i )->elems ) ;
> }
> free ( dfa->edests ) ;
> free ( dfa->eclosures ) ;
> free ( dfa->inveclosures ) ;
> free ( dfa->nodes ) ;
>
> if (dfa->state_table)
> for (i = 0; i <= dfa->state_hash_mask; ++i)
> {
> struct re_state_table_entry *entry = dfa->state_table + i;
> for (j = 0; j < entry->num; ++j)
> {
> re_dfastate_t *state = entry->array[j];
> free_state (state);
> }
> free ( entry->array ) ;
> }
> free ( dfa->state_table ) ;
>
>
>
>
> free ( dfa->subexp_map ) ;
>
>
>
>
> free ( dfa ) ;
> }
>
>
>
>
> void
> rpl_regfree (preg)
> regex_t *preg;
> {
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> if (( dfa != 0 ) )
> free_dfa_content (dfa);
> preg->buffer = 0 ;
> preg->allocated = 0;
>
> free ( preg->fastmap ) ;
> preg->fastmap = 0 ;
>
> free ( preg->translate ) ;
> preg->translate = 0 ;
> }
>
>
>
>
>
>
>
>
>
>
> static struct re_pattern_buffer re_comp_buf;
>
> char *
>
>
>
>
>
>
> rpl_re_comp (s)
> const char *s;
> {
> reg_errcode_t ret;
> char *fastmap;
>
> if (!s)
> {
> if (!re_comp_buf.buffer)
> return ( "No previous regular expression" ) ;
> return 0;
> }
>
> if (re_comp_buf.buffer)
> {
> fastmap = re_comp_buf.fastmap;
> re_comp_buf.fastmap = 0 ;
> rpl_regfree (&re_comp_buf);
> memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
> re_comp_buf.fastmap = fastmap;
> }
>
> if (re_comp_buf.fastmap == 0 )
> {
> re_comp_buf.fastmap = (char *) malloc ((0xff + 1) );
> if (re_comp_buf.fastmap == 0 )
> return (char *) ( __re_error_msgid
> + __re_error_msgid_idx[(int) _REG_ESPACE ] ) ;
> }
>
>
>
>
>
> re_comp_buf.newline_anchor = 1;
>
> ret = re_compile_internal (&re_comp_buf, s, strlen (s),
rpl_re_syntax_options );
>
> if (!ret)
> return 0 ;
>
>
> return (char *) ( __re_error_msgid + __re_error_msgid_idx[(int) ret] ) ;
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> static reg_errcode_t
> re_compile_internal (regex_t *preg, const char * pattern, size_t length,
> reg_syntax_t syntax)
> {
> reg_errcode_t err = _REG_NOERROR ;
> re_dfa_t *dfa;
> re_string_t regexp;
>
>
> preg->fastmap_accurate = 0;
> preg->syntax = syntax;
> preg->not_bol = preg->not_eol = 0;
> preg->used = 0;
> preg->re_nsub = 0;
> preg->can_be_null = 0;
> preg->regs_allocated = 0 ;
>
>
> dfa = (re_dfa_t *) preg->buffer;
> if (( preg->allocated < sizeof (re_dfa_t) ) )
> {
>
>
>
>
> dfa = (( re_dfa_t *) realloc ( preg->buffer , ( 1 ) * sizeof
( re_dfa_t ))) ;
> if (dfa == 0 )
> return _REG_ESPACE ;
> preg->allocated = sizeof (re_dfa_t);
> preg->buffer = (unsigned char *) dfa;
> }
> preg->used = sizeof (re_dfa_t);
>
> err = init_dfa (dfa, length);
> if (( err != _REG_NOERROR ) )
> {
> free_dfa_content (dfa);
> preg->buffer = 0 ;
> preg->allocated = 0;
> return err;
> }
>
>
>
>
>
>
> do { } while (0) ;
>
> err = re_string_construct (®exp, pattern, length, preg->translate,
> syntax & ((((((((((((((((((((((((unsigned long int)
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) , dfa);
> if (( err != _REG_NOERROR ) )
> {
> re_compile_internal_free_return:
> free_workarea_compile (preg);
> re_string_destruct (®exp);
> free_dfa_content (dfa);
> preg->buffer = 0 ;
> preg->allocated = 0;
> return err;
> }
>
>
> preg->re_nsub = 0;
> dfa->str_tree = parse (®exp, preg, syntax, &err);
> if (( dfa->str_tree == 0 ) )
> goto re_compile_internal_free_return;
>
>
> err = analyze (preg);
> if (( err != _REG_NOERROR ) )
> goto re_compile_internal_free_return;
>
>
>
>
>
>
>
>
> err = create_initial_state (dfa);
>
>
> free_workarea_compile (preg);
> re_string_destruct (®exp);
>
> if (( err != _REG_NOERROR ) )
> {
> free_dfa_content (dfa);
> preg->buffer = 0 ;
> preg->allocated = 0;
> }
>
> return err;
> }
>
>
>
>
> static reg_errcode_t
> init_dfa (re_dfa_t *dfa, size_t pat_len)
> {
> __re_size_t table_size;
>
> char *codeset_name;
>
> size_t max_object_size =
> (( sizeof (struct re_state_table_entry) ) < (
> (( sizeof (re_token_t) ) < (
> (( sizeof (re_node_set) ) < (
> (( sizeof (regmatch_t) ) < (
> (( sizeof (regoff_t) ) < (
> (( sizeof (wchar_t) ) < (
> (( sizeof (wctype_t) ) < (
> sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) ? ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) :
( sizeof (regoff_t) )) ) ? ( (( sizeof (regoff_t) ) <
( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) ? ( ((
sizeof (wchar_t) ) < ( (( sizeof (wctype_t) ) < ( !
> sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) : ( sizeof (regoff_t) )) ) : ( sizeof
(regmatch_t) )) ) ? ( (( sizeof (regmatch_t) ) <
( (( sizeof (regoff_t) ) < ( (( sizeof
(wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) ? ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) :
( size!
> of (regoff_t) )) ) ? ( (( sizeof (regoff_t) ) <
( !
> (( sizeof (wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) ? ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) :
( sizeof (regoff_t) )) ) : ( sizeof (regmatch_t) )) ) : ( sizeof
(re_node_set) )) ) ? ( (( sizeof (re_node_set) ) <
( (( sizeof (regmatch_t) ) < ( (( sizeof
(regoff_t) ) < ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype!
> _t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) ? ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) :
( sizeof (regoff_t) )) ) ? ( (( sizeof (regoff_t) ) <
( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) ? ( ((
sizeof (wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctyp!
> e_t) ) < ( sizeof (Idx) ) ?
( sizeof (!
> Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) : (
sizeof (regoff_t) )) ) : ( sizeof (regmatch_t) )) ) ? ( ((
sizeof (regmatch_t) ) < ( (( sizeof (regoff_t) ) <
( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) ? ( ((
sizeof (wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) : ( sizeof (regoff_t) )) ) ? ( ((
sizeof (regoff_t) ) < ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (!
> Idx) ) : ( sizeof (wctype_t) )) ) ? ( (( sizeof
(wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) ? ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) :
( sizeof (regoff_t) )) ) : ( sizeof (regmatch_t) )) ) : ( sizeof
(re_node_set) )) ) : ( sizeof (re_token_t) )) ) ? ( (( sizeof
(re_token_t) ) < ( (( sizeof (re_node_set) ) < (
(( sizeof (regmatch_t) ) < ( (( sizeof (regoff_t) ) <
( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( !
> sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wcha!
> r_t) )) ) ? ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) :
( sizeof (regoff_t) )) ) ? ( (( sizeof (regoff_t) ) <
( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) ? ( ((
sizeof (wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wcha!
> r_t) )) ) : ( sizeof (regoff_t) )) ) : ( sizeof (regmatch_t) )) ) ?
( (( sizeof (regmatch_t) ) < ( (( sizeof
(regoff_t) ) < ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) ?
( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) : ( sizeof (regoff_t) )) )
? ( (( sizeof (regoff_t) ) < ( (( sizeof
(wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( (( s!
> izeof (wctype_t) ) < ( sizeof (Idx) ) ?
( !
> sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) ))
) ? ( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) : ( sizeof (regoff_t) )) )
: ( sizeof (regmatch_t) )) ) : ( sizeof (re_node_set) )) ) ?
( (( sizeof (re_node_set) ) < ( (( sizeof
(regmatch_t) ) < ( (( sizeof (regoff_t) ) <
( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) ? ( ((
sizeof (wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? !
> ( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) : ( sizeof (regoff_t) )) )
? ( (( sizeof (regoff_t) ) < ( (( sizeof
(wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) ? ( (( sizeof (wchar_t) ) <
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) :
( sizeof (regoff_t) )) ) : ( sizeof (regmatch_t) )) ) ? (
(( sizeof (regmatch_t) ) < ( !
> (( sizeof (regoff_t) ) < ( (( sizeof (wchar_t) ) < ( !
> (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) ?
( (( sizeof (wchar_t) ) < ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ?
( (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) : ( sizeof (wchar_t) )) ) : ( sizeof (regoff_t) )) )
? ( (( sizeof (regoff_t) ) < ( (( sizeof
(wchar_t) ) < ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) ? ( ((
sizeof (wctype_t) ) < ( sizeof (Idx) ) ?
( sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : (
sizeof (wchar_t) )) ) ? ( (( sizeof (wchar_t) ) < ( !
> (( sizeof (wctype_t) ) < (
sizeof (Idx) ) ? ( sizeof (Idx) ) : ( sizeof
(wctype_t) )) ) ? ( (( sizeof (wctype_t) ) <
( sizeof (Idx) ) ? (
sizeof (Idx) ) : ( sizeof (wctype_t) )) ) : ( sizeof (wchar_t) )) ) :
( sizeof (regoff_t) )) ) : ( sizeof (regmatch_t) )) ) : ( sizeof
(re_node_set) )) ) : ( sizeof (re_token_t) )) ) : ( sizeof (struct
re_state_table_entry) )) ;
>
> memset (dfa, '\0', sizeof (re_dfa_t));
>
>
> dfa->str_tree_storage_idx = ((1024 - sizeof (void *)) / sizeof
(bin_tree_t)) ;
>
>
>
>
>
> if (( 4294967295U / max_object_size / 2 <= pat_len ) )
> return _REG_ESPACE ;
>
> dfa->nodes_alloc = pat_len + 1;
> dfa->nodes = (( re_token_t *) malloc (( dfa->nodes_alloc ) * sizeof
( re_token_t ))) ;
>
>
> for (table_size = 1; ; table_size <<= 1)
> if (table_size > pat_len)
> break;
>
> dfa->state_table = calloc (sizeof (struct re_state_table_entry),
table_size);
> dfa->state_hash_mask = table_size - 1;
>
> dfa->mb_cur_max = __mb_cur_max ;
>
>
>
>
>
>
>
>
> codeset_name = nl_langinfo (0 );
> # 892 "regcomp.c"
>
>
> if (rpl_strcasecmp (codeset_name, "UTF-8") == 0
> || rpl_strcasecmp (codeset_name, "UTF8") == 0)
> dfa->is_utf8 = 1;
>
>
>
> dfa->map_notascii = 0;
>
>
> # 930 "regcomp.c"
>
>
> if (( dfa->nodes == 0 || dfa->state_table == 0 ) )
> return _REG_ESPACE ;
> return _REG_NOERROR ;
> }
>
>
>
>
>
> static void
>
> init_word_char (re_dfa_t *dfa)
> {
> int i, j, ch;
> dfa->word_ops_used = 1;
> for (i = 0, ch = 0; i < (((0xff + 1) + 32 - 1) / 32 ) ; ++i)
> for (j = 0; j < 32 ; ++j, ++ch)
> if ((!!__maskrune(( ( ch ) ),( 0x00000100L | 0x00000400L )))
|| ch == '_')
> dfa->word_char[i] |= (bitset_word_t) 1 << j;
> }
>
>
>
> static void
> free_workarea_compile (regex_t *preg)
> {
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> bin_tree_storage_t *storage, *next;
> for (storage = dfa->str_tree_storage; storage; storage = next)
> {
> next = storage->next;
> free ( storage ) ;
> }
> dfa->str_tree_storage = 0 ;
> dfa->str_tree_storage_idx = ((1024 - sizeof (void *)) / sizeof
(bin_tree_t)) ;
> dfa->str_tree = 0 ;
> free ( dfa->org_indices ) ;
> dfa->org_indices = 0 ;
> }
>
>
>
> static reg_errcode_t
> create_initial_state (re_dfa_t *dfa)
> {
> Idx first, i;
> reg_errcode_t err;
> re_node_set init_nodes;
>
>
>
> first = dfa->str_tree->first->node_idx;
> dfa->init_node = first;
> err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
> if (( err != _REG_NOERROR ) )
> return err;
>
>
>
>
>
> if (dfa->nbackref > 0)
> for (i = 0; i < init_nodes.nelem; ++i)
> {
> Idx node_idx = init_nodes.elems[i];
> re_token_type_t type = dfa->nodes[node_idx].type;
>
> Idx clexp_idx;
> if (type != OP_BACK_REF)
> continue;
> for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx)
> {
> re_token_t *clexp_node;
> clexp_node = dfa->nodes + init_nodes.elems[clexp_idx];
> if (clexp_node->type == OP_CLOSE_SUBEXP
> && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx)
> break;
> }
> if (clexp_idx == init_nodes.nelem)
> continue;
>
> if (type == OP_BACK_REF)
> {
> Idx dest_idx = dfa->edests[node_idx].elems[0];
> if (!re_node_set_contains (&init_nodes, dest_idx))
> {
> re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx);
> i = 0;
> }
> }
> }
>
>
> dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
>
> if (( dfa->init_state == 0 ) )
> return err;
> if (dfa->init_state->has_constraint)
> {
> dfa->init_state_word = re_acquire_state_context (&err, dfa,
&init_nodes,
> 1 );
> dfa->init_state_nl = re_acquire_state_context (&err, dfa,
&init_nodes,
> (1 << 1) );
> dfa->init_state_begbuf = re_acquire_state_context (&err, dfa,
> &init_nodes,
> (1 << 1)
> | ((1 << 1) << 1) );
> if (( dfa->init_state_word == 0 || dfa->init_state_nl == 0
> || dfa->init_state_begbuf == 0 ) )
> return err;
> }
> else
> dfa->init_state_word = dfa->init_state_nl
> = dfa->init_state_begbuf = dfa->init_state;
>
> free ( ( &init_nodes )->elems ) ;
> return _REG_NOERROR ;
> }
>
> # 1129 "regcomp.c"
>
>
>
>
>
> static reg_errcode_t
> analyze (regex_t *preg)
> {
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> reg_errcode_t ret;
>
>
> dfa->nexts = (( Idx *) malloc (( dfa->nodes_alloc ) * sizeof ( Idx
))) ;
> dfa->org_indices = (( Idx *) malloc (( dfa->nodes_alloc ) * sizeof
( Idx ))) ;
> dfa->edests = (( re_node_set *) malloc (( dfa->nodes_alloc ) *
sizeof ( re_node_set ))) ;
> dfa->eclosures = (( re_node_set *) malloc (( dfa->nodes_alloc ) *
sizeof ( re_node_set ))) ;
> if (( dfa->nexts == 0 || dfa->org_indices == 0 || dfa->edests == 0
> || dfa->eclosures == 0 ) )
> return _REG_ESPACE ;
>
> dfa->subexp_map = (( Idx *) malloc (( preg->re_nsub ) * sizeof (
Idx ))) ;
> if (dfa->subexp_map != 0 )
> {
> Idx i;
> for (i = 0; i < preg->re_nsub; i++)
> dfa->subexp_map[i] = i;
> preorder (dfa->str_tree, optimize_subexps, dfa);
> for (i = 0; i < preg->re_nsub; i++)
> if (dfa->subexp_map[i] != i)
> break;
> if (i == preg->re_nsub)
> {
> free (dfa->subexp_map);
> dfa->subexp_map = 0 ;
> }
> }
>
> ret = postorder (dfa->str_tree, lower_subexps, preg);
> if (( ret != _REG_NOERROR ) )
> return ret;
> ret = postorder (dfa->str_tree, calc_first, dfa);
> if (( ret != _REG_NOERROR ) )
> return ret;
> preorder (dfa->str_tree, calc_next, dfa);
> ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
> if (( ret != _REG_NOERROR ) )
> return ret;
> ret = calc_eclosure (dfa);
> if (( ret != _REG_NOERROR ) )
> return ret;
>
>
>
> if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
> || dfa->nbackref)
> {
> dfa->inveclosures = (( re_node_set *) malloc (( dfa->nodes_len
) * sizeof ( re_node_set ))) ;
> if (( dfa->inveclosures == 0 ) )
> return _REG_ESPACE ;
> ret = calc_inveclosure (dfa);
> }
>
> return ret;
> }
>
>
>
>
> static reg_errcode_t
> postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
> void *extra)
> {
> bin_tree_t *node, *prev;
>
> for (node = root; ; )
> {
>
>
> while (node->left || node->right)
> if (node->left)
> node = node->left;
> else
> node = node->right;
>
> do
> {
> reg_errcode_t err = fn (extra, node);
> if (( err != _REG_NOERROR ) )
> return err;
> if (node->parent == 0 )
> return _REG_NOERROR ;
> prev = node;
> node = node->parent;
> }
>
> while (node->right == prev || node->right == 0 );
> node = node->right;
> }
> }
>
> static reg_errcode_t
> preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
> void *extra)
> {
> bin_tree_t *node;
>
> for (node = root; ; )
> {
> reg_errcode_t err = fn (extra, node);
> if (( err != _REG_NOERROR ) )
> return err;
>
>
> if (node->left)
> node = node->left;
> else
> {
> bin_tree_t *prev = 0 ;
> while (node->right == prev || node->right == 0 )
> {
> prev = node;
> node = node->parent;
> if (!node)
> return _REG_NOERROR ;
> }
> node = node->right;
> }
> }
> }
>
>
>
>
> static reg_errcode_t
> optimize_subexps (void *extra, bin_tree_t *node)
> {
> re_dfa_t *dfa = (re_dfa_t *) extra;
>
> if (node->token.type == OP_BACK_REF && dfa->subexp_map)
> {
> int idx = node->token.opr.idx;
> node->token.opr.idx = dfa->subexp_map[idx];
> dfa->used_bkref_map |= 1 << node->token.opr.idx;
> }
>
> else if (node->token.type == SUBEXP
> && node->left && node->left->token.type == SUBEXP)
> {
> Idx other_idx = node->left->token.opr.idx;
>
> node->left = node->left->left;
> if (node->left)
> node->left->parent = node;
>
> dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx];
> if (other_idx < 32 )
> dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx);
> }
>
> return _REG_NOERROR ;
> }
>
>
>
> static reg_errcode_t
> lower_subexps (void *extra, bin_tree_t *node)
> {
> regex_t *preg = (regex_t *) extra;
> reg_errcode_t err = _REG_NOERROR ;
>
> if (node->left && node->left->token.type == SUBEXP)
> {
> node->left = lower_subexp (&err, preg, node->left);
> if (node->left)
> node->left->parent = node;
> }
> if (node->right && node->right->token.type == SUBEXP)
> {
> node->right = lower_subexp (&err, preg, node->right);
> if (node->right)
> node->right->parent = node;
> }
>
> return err;
> }
>
> static bin_tree_t *
> lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
> {
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> bin_tree_t *body = node->left;
> bin_tree_t *op, *cls, *tree1, *tree;
>
> if (preg->no_sub
>
>
>
>
> && node->left != 0
> && (node->token.opr.idx >= 32
> || !(dfa->used_bkref_map
> & ((bitset_word_t) 1 << node->token.opr.idx))))
> return node->left;
>
>
>
> op = create_tree (dfa, 0 , 0 , OP_OPEN_SUBEXP);
> cls = create_tree (dfa, 0 , 0 , OP_CLOSE_SUBEXP);
> tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
> tree = create_tree (dfa, op, tree1, CONCAT);
> if (( tree == 0 || tree1 == 0 || op == 0 || cls == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
>
> op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx;
> op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp;
> return tree;
> }
>
>
>
> static reg_errcode_t
> calc_first (void *extra, bin_tree_t *node)
> {
> re_dfa_t *dfa = (re_dfa_t *) extra;
> if (node->token.type == CONCAT)
> {
> node->first = node->left->first;
> node->node_idx = node->left->node_idx;
> }
> else
> {
> node->first = node;
> node->node_idx = re_dfa_add_node (dfa, node->token);
> if (( node->node_idx == ((Idx) -1) ) )
> return _REG_ESPACE ;
> }
> return _REG_NOERROR ;
> }
>
>
> static reg_errcode_t
> calc_next (void *extra, bin_tree_t *node)
> {
> switch (node->token.type)
> {
> case OP_DUP_ASTERISK:
> node->left->next = node;
> break;
> case CONCAT:
> node->left->next = node->right->first;
> node->right->next = node->next;
> break;
> default:
> if (node->left)
> node->left->next = node->next;
> if (node->right)
> node->right->next = node->next;
> break;
> }
> return _REG_NOERROR ;
> }
>
>
> static reg_errcode_t
> link_nfa_nodes (void *extra, bin_tree_t *node)
> {
> re_dfa_t *dfa = (re_dfa_t *) extra;
> Idx idx = node->node_idx;
> reg_errcode_t err = _REG_NOERROR ;
>
> switch (node->token.type)
> {
> case CONCAT:
> break;
>
> case END_OF_RE:
> (( node->next == 0 ) ? (void)0 : __assert("regcomp.c", 1408,
"node->next == NULL")) ;
> break;
>
> case OP_DUP_ASTERISK:
> case OP_ALT:
> {
> Idx left, right;
> dfa->has_plural_match = 1;
> if (node->left != 0 )
> left = node->left->first->node_idx;
> else
> left = node->next->node_idx;
> if (node->right != 0 )
> right = node->right->first->node_idx;
> else
> right = node->next->node_idx;
> (( ((Idx) ( left ) < ((Idx) -2) ) ) ? (void)0 :
__assert("regcomp.c", 1424, "REG_VALID_INDEX (left)")) ;
> (( ((Idx) ( right ) < ((Idx) -2) ) ) ? (void)0 :
__assert("regcomp.c", 1425, "REG_VALID_INDEX (right)")) ;
> err = re_node_set_init_2 (dfa->edests + idx, left, right);
> }
> break;
>
> case ANCHOR:
> case OP_OPEN_SUBEXP:
> case OP_CLOSE_SUBEXP:
> err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx);
> break;
>
> case OP_BACK_REF:
> dfa->nexts[idx] = node->next->node_idx;
> if (node->token.type == OP_BACK_REF)
> re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]);
> break;
>
> default:
> (( ! (( node->token.type ) & 8 ) ) ? (void)0 :
__assert("regcomp.c", 1443, "!IS_EPSILON_NODE (node->token.type)")) ;
> dfa->nexts[idx] = node->next->node_idx;
> break;
> }
>
> return err;
> }
>
>
>
>
>
> static reg_errcode_t
>
> duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx
top_clone_node,
> Idx root_node, unsigned int init_constraint)
> {
> Idx org_node, clone_node;
> _Bool ok;
> unsigned int constraint = init_constraint;
> for (org_node = top_org_node, clone_node = top_clone_node;;)
> {
> Idx org_dest, clone_dest;
> if (dfa->nodes[org_node].type == OP_BACK_REF)
> {
>
>
>
>
> org_dest = dfa->nexts[org_node];
> (( dfa->edests + clone_node )->nelem = 0) ;
> clone_dest = duplicate_node (dfa, org_dest, constraint);
> if (( clone_dest == ((Idx) -1) ) )
> return _REG_ESPACE ;
> dfa->nexts[clone_node] = dfa->nexts[org_node];
> ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
> if (( ! ok ) )
> return _REG_ESPACE ;
> }
> else if (dfa->edests[org_node].nelem == 0)
> {
>
>
>
> dfa->nexts[clone_node] = dfa->nexts[org_node];
> break;
> }
> else if (dfa->edests[org_node].nelem == 1)
> {
>
>
> org_dest = dfa->edests[org_node].elems[0];
> (( dfa->edests + clone_node )->nelem = 0) ;
> if (dfa->nodes[org_node].type == ANCHOR)
> {
>
> if (org_node == root_node && clone_node != org_node)
> {
>
>
>
> ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
> if (( ! ok ) )
> return _REG_ESPACE ;
> break;
> }
> constraint |= dfa->nodes[org_node].opr.ctx_type;
> }
> clone_dest = duplicate_node (dfa, org_dest, constraint);
> if (( clone_dest == ((Idx) -1) ) )
> return _REG_ESPACE ;
> ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
> if (( ! ok ) )
> return _REG_ESPACE ;
> }
> else
> {
>
>
> org_dest = dfa->edests[org_node].elems[0];
> (( dfa->edests + clone_node )->nelem = 0) ;
>
> clone_dest = search_duplicated_node (dfa, org_dest, constraint);
> if (clone_dest == ((Idx) -1) )
> {
>
> reg_errcode_t err;
> clone_dest = duplicate_node (dfa, org_dest, constraint);
> if (( clone_dest == ((Idx) -1) ) )
> return _REG_ESPACE ;
> ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
> if (( ! ok ) )
> return _REG_ESPACE ;
> err = duplicate_node_closure (dfa, org_dest, clone_dest,
> root_node, constraint);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> else
> {
>
>
> ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
> if (( ! ok ) )
> return _REG_ESPACE ;
> }
>
> org_dest = dfa->edests[org_node].elems[1];
> clone_dest = duplicate_node (dfa, org_dest, constraint);
> if (( clone_dest == ((Idx) -1) ) )
> return _REG_ESPACE ;
> ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
> if (( ! ok ) )
> return _REG_ESPACE ;
> }
> org_node = org_dest;
> clone_node = clone_dest;
> }
> return _REG_NOERROR ;
> }
>
>
>
>
> static Idx
> search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
> unsigned int constraint)
> {
> Idx idx;
> for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0;
--idx)
> {
> if (org_node == dfa->org_indices[idx]
> && constraint == dfa->nodes[idx].constraint)
> return idx;
> }
> return ((Idx) -1) ;
> }
>
>
>
>
>
> static Idx
> duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
> {
> Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
> if (( dup_idx != ((Idx) -1) ) )
> {
> dfa->nodes[dup_idx].constraint = constraint;
> if (dfa->nodes[org_idx].type == ANCHOR)
> dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type;
> dfa->nodes[dup_idx].duplicated = 1;
>
>
> dfa->org_indices[dup_idx] = org_idx;
> }
> return dup_idx;
> }
>
> static reg_errcode_t
> calc_inveclosure (re_dfa_t *dfa)
> {
> Idx src, idx;
> _Bool ok;
> for (idx = 0; idx < dfa->nodes_len; ++idx)
> memset ( dfa->inveclosures + idx , '\0', sizeof (re_node_set)) ;
>
> for (src = 0; src < dfa->nodes_len; ++src)
> {
> Idx *elems = dfa->eclosures[src].elems;
> for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
> {
> ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
> if (( ! ok ) )
> return _REG_ESPACE ;
> }
> }
>
> return _REG_NOERROR ;
> }
>
>
>
> static reg_errcode_t
> calc_eclosure (re_dfa_t *dfa)
> {
> Idx node_idx;
> _Bool incomplete;
>
>
>
> incomplete = 0 ;
>
> for (node_idx = 0; ; ++node_idx)
> {
> reg_errcode_t err;
> re_node_set eclosure_elem;
> if (node_idx == dfa->nodes_len)
> {
> if (!incomplete)
> break;
> incomplete = 0 ;
> node_idx = 0;
> }
>
>
>
>
>
>
> if (dfa->eclosures[node_idx].nelem != 0)
> continue;
>
> err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, 1 );
> if (( err != _REG_NOERROR ) )
> return err;
>
> if (dfa->eclosures[node_idx].nelem == 0)
> {
> incomplete = 1 ;
> free ( ( &eclosure_elem )->elems ) ;
> }
> }
> return _REG_NOERROR ;
> }
>
>
>
> static reg_errcode_t
> calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node,
_Bool root)
> {
> reg_errcode_t err;
> unsigned int constraint;
> Idx i;
> _Bool incomplete;
> _Bool ok;
> re_node_set eclosure;
> incomplete = 0 ;
> err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
> if (( err != _REG_NOERROR ) )
> return err;
>
>
>
> dfa->eclosures[node].nelem = ((Idx) -1) ;
>
> constraint = ((dfa->nodes[node].type == ANCHOR)
> ? dfa->nodes[node].opr.ctx_type : 0);
>
>
> if (constraint
> && dfa->edests[node].nelem
> && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
> {
> err = duplicate_node_closure (dfa, node, node, node, constraint);
> if (( err != _REG_NOERROR ) )
> return err;
> }
>
>
> if ((( dfa->nodes[node].type ) & 8 ) )
> for (i = 0; i < dfa->edests[node].nelem; ++i)
> {
> re_node_set eclosure_elem;
> Idx edest = dfa->edests[node].elems[i];
>
>
> if (dfa->eclosures[edest].nelem == ((Idx) -1) )
> {
> incomplete = 1 ;
> continue;
> }
>
>
> if (dfa->eclosures[edest].nelem == 0)
> {
> err = calc_eclosure_iter (&eclosure_elem, dfa, edest, 0 );
> if (( err != _REG_NOERROR ) )
> return err;
> }
> else
> eclosure_elem = dfa->eclosures[edest];
>
> re_node_set_merge (&eclosure, &eclosure_elem);
>
>
> if (dfa->eclosures[edest].nelem == 0)
> {
> incomplete = 1 ;
> free ( ( &eclosure_elem )->elems ) ;
> }
> }
>
>
> ok = re_node_set_insert (&eclosure, node);
> if (( ! ok ) )
> return _REG_ESPACE ;
> if (incomplete && !root)
> dfa->eclosures[node].nelem = 0;
> else
> dfa->eclosures[node] = eclosure;
> *new_set = eclosure;
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
> static void
>
> fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
> {
> (( input )->cur_idx += ( peek_token (result, input, syntax) )) ;
> }
>
>
>
>
> static int
>
> peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
> {
> unsigned char c;
>
> if ((( input )->stop <= ( input )->cur_idx) )
> {
> token->type = END_OF_RE;
> return 0;
> }
>
> c = (( input )->mbs[( input )->cur_idx + 0 ]) ;
> token->opr.c = c;
>
> token->word_char = 0;
> # 1788 "regcomp.c"
>
> if (c == '\\')
> {
> unsigned char c2;
> if ((( input )->cur_idx) + 1 >= (( input )->len) )
> {
> token->type = BACK_SLASH;
> return 1;
> }
>
> c2 = re_string_peek_byte_case (input, 1);
> token->opr.c = c2;
> token->type = CHARACTER;
> # 1809 "regcomp.c"
>
> token->word_char = ((!!__maskrune(( ( c2 ) ),( 0x00000100L |
0x00000400L ))) || ( c2 ) == '_') != 0;
>
> switch (c2)
> {
> case '|':
> if (!(syntax & ((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ) && !(syntax &
(((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> token->type = OP_ALT;
> break;
> case '1': case '2': case '3': case '4': case '5':
> case '6': case '7': case '8': case '9':
> if (!(syntax & ((((((((((((((((unsigned long int) 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) ))
> {
> token->type = OP_BACK_REF;
> token->opr.idx = c2 - '1';
> }
> break;
> case '<':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> {
> token->type = ANCHOR;
> token->opr.ctx_type = WORD_FIRST;
> }
> break;
> case '>':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> {
> token->type = ANCHOR;
> token->opr.ctx_type = WORD_LAST;
> }
> break;
> case 'b':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> {
> token->type = ANCHOR;
> token->opr.ctx_type = WORD_DELIM;
> }
> break;
> case 'B':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> {
> token->type = ANCHOR;
> token->opr.ctx_type = NOT_WORD_DELIM;
> }
> break;
> case 'w':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> token->type = OP_WORD;
> break;
> case 'W':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> token->type = OP_NOTWORD;
> break;
> case 's':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> token->type = OP_SPACE;
> break;
> case 'S':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> token->type = OP_NOTSPACE;
> break;
> case '`':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> {
> token->type = ANCHOR;
> token->opr.ctx_type = BUF_FIRST;
> }
> break;
> case '\'':
> if (!(syntax & (((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> {
> token->type = ANCHOR;
> token->opr.ctx_type = BUF_LAST;
> }
> break;
> case '(':
> if (!(syntax & (((((((((((((((unsigned long int) 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) ))
> token->type = OP_OPEN_SUBEXP;
> break;
> case ')':
> if (!(syntax & (((((((((((((((unsigned long int) 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) ))
> token->type = OP_CLOSE_SUBEXP;
> break;
> case '+':
> if (!(syntax & ((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ) && (syntax &
(((unsigned long int) 1) << 1) ))
> token->type = OP_DUP_PLUS;
> break;
> case '?':
> if (!(syntax & ((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ) && (syntax &
(((unsigned long int) 1) << 1) ))
> token->type = OP_DUP_QUESTION;
> break;
> case '{':
> if ((syntax & (((((((((((unsigned long int) 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) ) && (!(syntax &
((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) )))
> token->type = OP_OPEN_DUP_NUM;
> break;
> case '}':
> if ((syntax & (((((((((((unsigned long int) 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) ) && (!(syntax &
((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) )))
> token->type = OP_CLOSE_DUP_NUM;
> break;
> default:
> break;
> }
> return 2;
> }
>
> token->type = CHARACTER;
>
>
>
>
>
>
>
>
> token->word_char = ((!!__maskrune(( ( token->opr.c ) ),(
0x00000100L | 0x00000400L ))) || ( token->opr.c ) == '_') ;
>
> switch (c)
> {
> case '\n':
> if (syntax & (((((((((((((unsigned long int) 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) )
> token->type = OP_ALT;
> break;
> case '|':
> if (!(syntax & ((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ) && (syntax &
(((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> token->type = OP_ALT;
> break;
> case '*':
> token->type = OP_DUP_ASTERISK;
> break;
> case '+':
> if (!(syntax & ((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ) && !(syntax &
(((unsigned long int) 1) << 1) ))
> token->type = OP_DUP_PLUS;
> break;
> case '?':
> if (!(syntax & ((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ) && !(syntax &
(((unsigned long int) 1) << 1) ))
> token->type = OP_DUP_QUESTION;
> break;
> case '{':
> if ((syntax & (((((((((((unsigned long int) 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) ) && (syntax &
((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> token->type = OP_OPEN_DUP_NUM;
> break;
> case '}':
> if ((syntax & (((((((((((unsigned long int) 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) ) && (syntax &
((((((((((((((unsigned long int) 1) << 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> token->type = OP_CLOSE_DUP_NUM;
> break;
> case '(':
> if (syntax & (((((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) )
> token->type = OP_OPEN_SUBEXP;
> break;
> case ')':
> if (syntax & (((((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) )
> token->type = OP_CLOSE_SUBEXP;
> break;
> case '[':
> token->type = OP_OPEN_BRACKET;
> break;
> case '.':
> token->type = OP_PERIOD;
> break;
> case '^':
> if (!(syntax & ((((((unsigned long int) 1) << 1) << 1) << 1)
| (((((((((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) )) &&
> (( input )->cur_idx) != 0)
> {
> char prev = (( input )->mbs[( input )->cur_idx + -1 ]) ;
> if (!(syntax & (((((((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) ) || prev
!= '\n')
> break;
> }
> token->type = ANCHOR;
> token->opr.ctx_type = LINE_FIRST;
> break;
> case '$':
> if (!(syntax & (((((unsigned long int) 1) << 1) << 1) << 1) ) &&
> (( input )->cur_idx) + 1 != (( input )->len) )
> {
> re_token_t next;
> (( input )->cur_idx += ( 1 )) ;
> peek_token (&next, input, syntax);
> (( input )->cur_idx += ( -1 )) ;
> if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP)
> break;
> }
> token->type = ANCHOR;
> token->opr.ctx_type = LINE_LAST;
> break;
> default:
> break;
> }
> return 1;
> }
>
>
>
>
> static int
>
> peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t
syntax)
> {
> unsigned char c;
> if ((( input )->stop <= ( input )->cur_idx) )
> {
> token->type = END_OF_RE;
> return 0;
> }
> c = (( input )->mbs[( input )->cur_idx + 0 ]) ;
> token->opr.c = c;
>
>
>
>
>
>
>
>
>
>
> if (c == '\\' && (syntax & ((unsigned long int) 1) )
> && (( input )->cur_idx) + 1 < (( input )->len) )
> {
>
> unsigned char c2;
> (( input )->cur_idx += ( 1 )) ;
> c2 = (( input )->mbs[( input )->cur_idx + 0 ]) ;
> token->opr.c = c2;
> token->type = CHARACTER;
> return 1;
> }
> if (c == '[')
> {
> unsigned char c2;
> int token_len;
> if ((( input )->cur_idx) + 1 < (( input )->len) )
> c2 = (( input )->mbs[( input )->cur_idx + 1 ]) ;
> else
> c2 = 0;
> token->opr.c = c2;
> token_len = 2;
> switch (c2)
> {
> case '.':
> token->type = OP_OPEN_COLL_ELEM;
> break;
> case '=':
> token->type = OP_OPEN_EQUIV_CLASS;
> break;
> case ':':
> if (syntax & ((((unsigned long int) 1) << 1) << 1) )
> {
> token->type = OP_OPEN_CHAR_CLASS;
> break;
> }
>
> default:
> token->type = CHARACTER;
> token->opr.c = c;
> token_len = 1;
> break;
> }
> return token_len;
> }
> switch (c)
> {
> case '-':
> token->type = OP_CHARSET_RANGE;
> break;
> case ']':
> token->type = OP_CLOSE_BRACKET;
> break;
> case '^':
> token->type = OP_NON_MATCH_LIST;
> break;
> default:
> token->type = CHARACTER;
> }
> return 1;
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> static bin_tree_t *
> parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
> reg_errcode_t *err)
> {
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> bin_tree_t *tree, *eor, *root;
> re_token_t current_token;
> dfa->syntax = syntax;
> fetch_token (¤t_token, regexp, syntax |
(((((((((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) );
> tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err);
> if (( *err != _REG_NOERROR && tree == 0 ) )
> return 0 ;
> eor = create_tree (dfa, 0 , 0 , END_OF_RE);
> if (tree != 0 )
> root = create_tree (dfa, tree, eor, CONCAT);
> else
> root = eor;
> if (( eor == 0 || root == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> return root;
> }
>
>
>
>
>
>
>
>
>
>
> static bin_tree_t *
> parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
> reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
> {
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> bin_tree_t *tree, *branch = 0 ;
> tree = parse_branch (regexp, preg, token, syntax, nest, err);
> if (( *err != _REG_NOERROR && tree == 0 ) )
> return 0 ;
>
> while (token->type == OP_ALT)
> {
> fetch_token (token, regexp, syntax |
(((((((((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) );
> if (token->type != OP_ALT && token->type != END_OF_RE
> && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
> {
> branch = parse_branch (regexp, preg, token, syntax, nest, err);
> if (( *err != _REG_NOERROR && branch == 0 ) )
> return 0 ;
> }
> else
> branch = 0 ;
> tree = create_tree (dfa, tree, branch, OP_ALT);
> if (( tree == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> }
> return tree;
> }
>
>
>
>
>
>
>
>
>
>
> static bin_tree_t *
> parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
> reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
> {
> bin_tree_t *tree, *exp;
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> tree = parse_expression (regexp, preg, token, syntax, nest, err);
> if (( *err != _REG_NOERROR && tree == 0 ) )
> return 0 ;
>
> while (token->type != OP_ALT && token->type != END_OF_RE
> && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
> {
> exp = parse_expression (regexp, preg, token, syntax, nest, err);
> if (( *err != _REG_NOERROR && exp == 0 ) )
> {
> return 0 ;
> }
> if (tree != 0 && exp != 0 )
> {
> tree = create_tree (dfa, tree, exp, CONCAT);
> if (tree == 0 )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> }
> else if (tree == 0 )
> tree = exp;
>
> }
> return tree;
> }
>
>
>
>
>
>
>
> static bin_tree_t *
> parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
> reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
> {
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> bin_tree_t *tree;
> switch (token->type)
> {
> case CHARACTER:
> tree = create_token_tree (dfa, 0 , 0 , token);
> if (( tree == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> # 2246 "regcomp.c"
>
> break;
> case OP_OPEN_SUBEXP:
> tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
> if (( *err != _REG_NOERROR && tree == 0 ) )
> return 0 ;
> break;
> case OP_OPEN_BRACKET:
> tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
> if (( *err != _REG_NOERROR && tree == 0 ) )
> return 0 ;
> break;
> case OP_BACK_REF:
> if (! ( dfa->completed_bkref_map & (1 << token->opr.idx) ) )
> {
> *err = _REG_ESUBREG ;
> return 0 ;
> }
> dfa->used_bkref_map |= 1 << token->opr.idx;
> tree = create_token_tree (dfa, 0 , 0 , token);
> if (( tree == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> ++dfa->nbackref;
> dfa->has_mb_node = 1;
> break;
> case OP_OPEN_DUP_NUM:
> if (syntax & ((((((((((((((((((((((((((unsigned long int) 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) )
> {
> *err = _REG_BADRPT ;
> return 0 ;
> }
>
> case OP_DUP_ASTERISK:
> case OP_DUP_PLUS:
> case OP_DUP_QUESTION:
> if (syntax & (((((((unsigned long int) 1) << 1) << 1) << 1)
<< 1) << 1) )
> {
> *err = _REG_BADRPT ;
> return 0 ;
> }
> else if (syntax & ((((((unsigned long int) 1) << 1) << 1) <<
1) << 1) )
> {
> fetch_token (token, regexp, syntax);
> return parse_expression (regexp, preg, token, syntax, nest, err);
> }
>
> case OP_CLOSE_SUBEXP:
> if ((token->type == OP_CLOSE_SUBEXP) &&
> !(syntax & (((((((((((((((((((unsigned long int) 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) ))
> {
> *err = _REG_ERPAREN ;
> return 0 ;
> }
>
> case OP_CLOSE_DUP_NUM:
>
>
>
> token->type = CHARACTER;
>
>
> tree = create_token_tree (dfa, 0 , 0 , token);
> if (( tree == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> break;
> case ANCHOR:
> if ((token->opr.ctx_type
> & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
> && dfa->word_ops_used == 0)
> init_word_char (dfa);
> if (token->opr.ctx_type == WORD_DELIM
> || token->opr.ctx_type == NOT_WORD_DELIM)
> {
> bin_tree_t *tree_first, *tree_last;
> if (token->opr.ctx_type == WORD_DELIM)
> {
> token->opr.ctx_type = WORD_FIRST;
> tree_first = create_token_tree (dfa, 0 , 0 , token);
> token->opr.ctx_type = WORD_LAST;
> }
> else
> {
> token->opr.ctx_type = INSIDE_WORD;
> tree_first = create_token_tree (dfa, 0 , 0 , token);
> token->opr.ctx_type = INSIDE_NOTWORD;
> }
> tree_last = create_token_tree (dfa, 0 , 0 , token);
> tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
> if (( tree_first == 0 || tree_last == 0 || tree == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> }
> else
> {
> tree = create_token_tree (dfa, 0 , 0 , token);
> if (( tree == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> }
>
>
>
>
> fetch_token (token, regexp, syntax);
> return tree;
> case OP_PERIOD:
> tree = create_token_tree (dfa, 0 , 0 , token);
> if (( tree == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> if (dfa->mb_cur_max > 1)
> dfa->has_mb_node = 1;
> break;
> case OP_WORD:
> case OP_NOTWORD:
> tree = build_charclass_op (dfa, regexp->trans,
> (const unsigned char *) "alnum",
> (const unsigned char *) "_",
> token->type == OP_NOTWORD, err);
> if (( *err != _REG_NOERROR && tree == 0 ) )
> return 0 ;
> break;
> case OP_SPACE:
> case OP_NOTSPACE:
> tree = build_charclass_op (dfa, regexp->trans,
> (const unsigned char *) "space",
> (const unsigned char *) "",
> token->type == OP_NOTSPACE, err);
> if (( *err != _REG_NOERROR && tree == 0 ) )
> return 0 ;
> break;
> case OP_ALT:
> case END_OF_RE:
> return 0 ;
> case BACK_SLASH:
> *err = _REG_EESCAPE ;
> return 0 ;
> default:
>
>
>
>
> return 0 ;
> }
> fetch_token (token, regexp, syntax);
>
> while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
> || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
> {
> tree = parse_dup_op (tree, regexp, dfa, token, syntax, err);
> if (( *err != _REG_NOERROR && tree == 0 ) )
> return 0 ;
>
> if ((syntax & ((((((((((((((((((((((((((unsigned long int) 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) )
> && (token->type == OP_DUP_ASTERISK
> || token->type == OP_OPEN_DUP_NUM))
> {
> *err = _REG_BADRPT ;
> return 0 ;
> }
> }
>
> return tree;
> }
>
>
>
>
>
>
>
>
> static bin_tree_t *
> parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
> reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
> {
> re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
> bin_tree_t *tree;
> size_t cur_nsub;
> cur_nsub = preg->re_nsub++;
>
> fetch_token (token, regexp, syntax |
(((((((((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) );
>
>
> if (token->type == OP_CLOSE_SUBEXP)
> tree = 0 ;
> else
> {
> tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
> if (( *err == _REG_NOERROR && token->type != OP_CLOSE_SUBEXP ) )
> *err = _REG_EPAREN ;
> if (( *err != _REG_NOERROR ) )
> return 0 ;
> }
>
> if (cur_nsub <= '9' - '1')
> dfa->completed_bkref_map |= 1 << cur_nsub;
>
> tree = create_tree (dfa, tree, 0 , SUBEXP);
> if (( tree == 0 ) )
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
> tree->token.opr.idx = cur_nsub;
> return tree;
> }
>
>
>
> static bin_tree_t *
> parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
> re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err)
> {
> bin_tree_t *tree = 0 , *old_tree = 0 ;
> Idx i, start, end, start_idx = (( regexp )->cur_idx) ;
> re_token_t start_token = *token;
>
> if (token->type == OP_OPEN_DUP_NUM)
> {
> end = 0;
> start = fetch_number (regexp, token, syntax);
> if (start == ((Idx) -1) )
> {
> if (token->type == CHARACTER && token->opr.c == ',')
> start = 0;
> else
> {
> *err = _REG_BADBR ;
> return 0 ;
> }
> }
> if (( start != ((Idx) -2) ) )
> {
>
> end = ((token->type == OP_CLOSE_DUP_NUM) ? start
> : ((token->type == CHARACTER && token->opr.c == ',')
> ? fetch_number (regexp, token, syntax) : ((Idx) -2) ));
> }
> if (( start == ((Idx) -2) || end == ((Idx) -2) ) )
> {
>
> if (( !(syntax & (((((((((((((((((((((((unsigned long int) 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1)
) ) )
> {
> if (token->type == END_OF_RE)
> *err = _REG_EBRACE ;
> else
> *err = _REG_BADBR ;
>
> return 0 ;
> }
>
>
> (( regexp )->cur_idx = ( start_idx )) ;
> *token = start_token;
> token->type = CHARACTER;
>
>
> return elem;
> }
>
> if (( end != ((Idx) -1) && start > end ) )
> {
>
> *err = _REG_BADBR ;
> return 0 ;
> }
> }
> else
> {
> start = (token->type == OP_DUP_PLUS) ? 1 : 0;
> end = (token->type == OP_DUP_QUESTION) ? 1 : ((Idx) -1) ;
> }
>
> fetch_token (token, regexp, syntax);
>
> if (( elem == 0 ) )
> return 0 ;
> if (( start == 0 && end == 0 ) )
> {
> postorder (elem, free_tree, 0 );
> return 0 ;
> }
>
>
> if (( start > 0 ) )
> {
> tree = elem;
> for (i = 2; i <= start; ++i)
> {
> elem = duplicate_tree (elem, dfa);
> tree = create_tree (dfa, tree, elem, CONCAT);
> if (( elem == 0 || tree == 0 ) )
> goto parse_dup_op_espace;
> }
>
> if (start == end)
> return tree;
>
>
> elem = duplicate_tree (elem, dfa);
> old_tree = tree;
> }
> else
> old_tree = 0 ;
>
> if (elem->token.type == SUBEXP)
> postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx);
>
> tree = create_tree (dfa, elem, 0 ,
> (end == ((Idx) -1) ? OP_DUP_ASTERISK : OP_ALT));
> if (( tree == 0 ) )
> goto parse_dup_op_espace;
>
>
>
>
> if ((Idx) -1 < 0 || end != ((Idx) -1) )
> for (i = start + 2; i <= end; ++i)
> {
> elem = duplicate_tree (elem, dfa);
> tree = create_tree (dfa, tree, elem, CONCAT);
> if (( elem == 0 || tree == 0 ) )
> goto parse_dup_op_espace;
>
> tree = create_tree (dfa, tree, 0 , OP_ALT);
> if (( tree == 0 ) )
> goto parse_dup_op_espace;
> }
>
> if (old_tree)
> tree = create_tree (dfa, old_tree, tree, CONCAT);
>
> return tree;
>
> parse_dup_op_espace:
> *err = _REG_ESPACE ;
> return 0 ;
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
> static reg_errcode_t
>
>
>
>
>
> build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem,
> bracket_elem_t *end_elem)
>
> {
> unsigned int start_ch, end_ch;
>
> if (( start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
> || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS ) )
>
> return _REG_ERANGE ;
>
>
>
> if (( (start_elem->type == COLL_SYM
> && strlen ((char *) start_elem->opr.name) > 1)
> || (end_elem->type == COLL_SYM
> && strlen ((char *) end_elem->opr.name) > 1) ) )
> return _REG_ECOLLATE ;
>
> # 2703 "regcomp.c"
>
> {
> unsigned int ch;
> start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
> : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
> : 0));
> end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
> : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
> : 0));
> if (start_ch > end_ch)
> return _REG_ERANGE ;
>
> for (ch = 0; ch < (0xff + 1) ; ++ch)
> if (start_ch <= ch && ch <= end_ch)
> bitset_set (sbcset, ch);
> }
>
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
>
>
>
> static reg_errcode_t
>
> build_collating_symbol (bitset_t sbcset,
>
>
>
> const unsigned char *name)
> {
> size_t name_len = strlen ((const char *) name);
> if (( name_len != 1 ) )
> return _REG_ECOLLATE ;
> else
> {
> bitset_set (sbcset, name[0]);
> return _REG_NOERROR ;
> }
> }
>
>
>
>
>
> static bin_tree_t *
> parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
> reg_syntax_t syntax, reg_errcode_t *err)
> {
> # 3018 "regcomp.c"
>
>
> re_token_t br_token;
> re_bitset_ptr_t sbcset;
>
>
>
>
>
> _Bool non_match = 0 ;
> bin_tree_t *work_tree;
> int token_len;
> _Bool first_round = 1 ;
> # 3047 "regcomp.c"
>
> sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
>
>
>
>
>
>
> if (( sbcset == 0 ) )
>
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
>
> token_len = peek_token_bracket (token, regexp, syntax);
> if (( token->type == END_OF_RE ) )
> {
> *err = _REG_BADPAT ;
> goto parse_bracket_exp_free_return;
> }
> if (token->type == OP_NON_MATCH_LIST)
> {
>
>
>
> non_match = 1 ;
> if (syntax & ((((((((((unsigned long int) 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) )
> bitset_set (sbcset, '\0');
> (( regexp )->cur_idx += ( token_len )) ;
> token_len = peek_token_bracket (token, regexp, syntax);
> if (( token->type == END_OF_RE ) )
> {
> *err = _REG_BADPAT ;
> goto parse_bracket_exp_free_return;
> }
> }
>
>
> if (token->type == OP_CLOSE_BRACKET)
> token->type = CHARACTER;
>
> while (1)
> {
> bracket_elem_t start_elem, end_elem;
> unsigned char start_name_buf[32 ];
> unsigned char end_name_buf[32 ];
> reg_errcode_t ret;
> int token_len2 = 0;
> _Bool is_range_exp = 0 ;
> re_token_t token2;
>
> start_elem.opr.name = start_name_buf;
> ret = parse_bracket_element (&start_elem, regexp, token,
token_len, dfa,
> syntax, first_round);
> if (( ret != _REG_NOERROR ) )
> {
> *err = ret;
> goto parse_bracket_exp_free_return;
> }
> first_round = 0 ;
>
>
> token_len = peek_token_bracket (token, regexp, syntax);
>
>
> if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
> {
> if (( token->type == END_OF_RE ) )
> {
> *err = _REG_EBRACK ;
> goto parse_bracket_exp_free_return;
> }
> if (token->type == OP_CHARSET_RANGE)
> {
> (( regexp )->cur_idx += ( token_len )) ;
> token_len2 = peek_token_bracket (&token2, regexp, syntax);
> if (( token2.type == END_OF_RE ) )
> {
> *err = _REG_EBRACK ;
> goto parse_bracket_exp_free_return;
> }
> if (token2.type == OP_CLOSE_BRACKET)
> {
>
> (( regexp )->cur_idx += ( -token_len )) ;
> token->type = CHARACTER;
> }
> else
> is_range_exp = 1 ;
> }
> }
>
> if (is_range_exp == 1 )
> {
> end_elem.opr.name = end_name_buf;
> ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
> dfa, syntax, 1 );
> if (( ret != _REG_NOERROR ) )
> {
> *err = ret;
> goto parse_bracket_exp_free_return;
> }
>
> token_len = peek_token_bracket (token, regexp, syntax);
>
>
>
>
>
>
>
>
>
>
> *err = build_range_exp (sbcset, &start_elem, &end_elem);
>
>
> if (( *err != _REG_NOERROR ) )
> goto parse_bracket_exp_free_return;
> }
> else
> {
> switch (start_elem.type)
> {
> case SB_CHAR:
> bitset_set (sbcset, start_elem.opr.ch);
> break;
> # 3193 "regcomp.c"
>
> case EQUIV_CLASS:
> *err = build_equiv_class (sbcset,
>
>
>
> start_elem.opr.name);
> if (( *err != _REG_NOERROR ) )
> goto parse_bracket_exp_free_return;
> break;
> case COLL_SYM:
> *err = build_collating_symbol (sbcset,
>
>
>
> start_elem.opr.name);
> if (( *err != _REG_NOERROR ) )
> goto parse_bracket_exp_free_return;
> break;
> case CHAR_CLASS:
> *err = build_charclass (regexp->trans, sbcset,
>
>
>
> start_elem.opr.name, syntax);
> if (( *err != _REG_NOERROR ) )
> goto parse_bracket_exp_free_return;
> break;
> default:
> (( 0 ) ? (void)0 : __assert("regcomp.c", 3222, "0")) ;
> break;
> }
> }
> if (( token->type == END_OF_RE ) )
> {
> *err = _REG_EBRACK ;
> goto parse_bracket_exp_free_return;
> }
> if (token->type == OP_CLOSE_BRACKET)
> break;
> }
>
> (( regexp )->cur_idx += ( token_len )) ;
>
>
> if (non_match)
> bitset_not (sbcset);
>
> # 3285 "regcomp.c"
>
> {
>
>
>
>
> br_token.type = SIMPLE_BRACKET;
> br_token.opr.sbcset = sbcset;
> work_tree = create_token_tree (dfa, 0 , 0 , &br_token);
> if (( work_tree == 0 ) )
> goto parse_bracket_exp_espace;
> }
> return work_tree;
>
> parse_bracket_exp_espace:
> *err = _REG_ESPACE ;
> parse_bracket_exp_free_return:
> free ( sbcset ) ;
>
>
>
> return 0 ;
> }
>
>
>
> static reg_errcode_t
> parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
> re_token_t *token, int token_len, re_dfa_t *dfa,
> reg_syntax_t syntax, _Bool accept_hyphen)
> {
> # 3326 "regcomp.c"
>
> (( regexp )->cur_idx += ( token_len )) ;
> if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
> || token->type == OP_OPEN_EQUIV_CLASS)
> return parse_bracket_symbol (elem, regexp, token);
> if (( token->type == OP_CHARSET_RANGE ) && !accept_hyphen)
> {
>
>
> re_token_t token2;
> (void) peek_token_bracket (&token2, regexp, syntax);
> if (token2.type != OP_CLOSE_BRACKET)
>
>
> return _REG_ERANGE ;
> }
> elem->type = SB_CHAR;
> elem->opr.ch = token->opr.c;
> return _REG_NOERROR ;
> }
>
>
>
>
>
> static reg_errcode_t
> parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
> re_token_t *token)
> {
> unsigned char ch, delim = token->opr.c;
> int i = 0;
> if ((( regexp )->stop <= ( regexp )->cur_idx) )
> return _REG_EBRACK ;
> for (;; ++i)
> {
> if (i >= 32 )
> return _REG_EBRACK ;
> if (token->type == OP_OPEN_CHAR_CLASS)
> ch = re_string_fetch_byte_case (regexp);
> else
> ch = (( regexp )->mbs[( regexp )->cur_idx++]) ;
> if ((( regexp )->stop <= ( regexp )->cur_idx) )
> return _REG_EBRACK ;
> if (ch == delim && (( regexp )->mbs[( regexp )->cur_idx + 0 ])
== ']')
> break;
> elem->opr.name[i] = ch;
> }
> (( regexp )->cur_idx += ( 1 )) ;
> elem->opr.name[i] = '\0';
> switch (token->type)
> {
> case OP_OPEN_COLL_ELEM:
> elem->type = COLL_SYM;
> break;
> case OP_OPEN_EQUIV_CLASS:
> elem->type = EQUIV_CLASS;
> break;
> case OP_OPEN_CHAR_CLASS:
> elem->type = CHAR_CLASS;
> break;
> default:
> break;
> }
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
>
> static reg_errcode_t
>
>
>
>
> build_equiv_class (bitset_t sbcset, const unsigned char *name)
>
> {
> # 3475 "regcomp.c"
>
> {
> if (( strlen ((const char *) name) != 1 ) )
> return _REG_ECOLLATE ;
> bitset_set (sbcset, *name);
> }
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
>
> static reg_errcode_t
>
>
>
>
>
> build_charclass (unsigned char * trans, bitset_t sbcset,
> const unsigned char *class_name, reg_syntax_t syntax)
>
> {
> int i;
> const char *name = (const char *) class_name;
>
>
>
> if ((syntax & ((((((((((((((((((((((((unsigned long int) 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) )
> && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
> name = "alpha";
>
> # 3525 "regcomp.c"
>
>
>
> # 3542 "regcomp.c"
>
> if (strcmp (name, "alnum") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00000100L | 0x00000400L )))
) bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00000100L |
0x00000400L ))) ) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "cntrl") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00000200L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00000200L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "lower") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00001000L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00001000L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "space") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00004000L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00004000L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "alpha") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00000100L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00000100L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "digit") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( __isctype(( i ), 0x00000400L ) ) bitset_set (sbcset,
trans[i]); } else { for (i = 0; i < (0xff + 1) ; ++i) if
( __isctype(( i ), 0x00000400L ) ) bitset_set (sbcset, i); } }
while (0) ;
> else if (strcmp (name, "print") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00040000L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00040000L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "upper") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00008000L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00008000L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "blank") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00020000L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00020000L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "graph") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00000800L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00000800L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "punct") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( (!!__maskrune(( ( i ) ),( 0x00002000L ))) )
bitset_set (sbcset, trans[i]); } else { for (i = 0; i <
(0xff + 1) ; ++i) if ( (!!__maskrune(( ( i ) ),( 0x00002000L )))
) bitset_set (sbcset, i); } } while (0) ;
> else if (strcmp (name, "xdigit") == 0)
> do { if (( trans != 0 ) ) { for (i = 0; i < (0xff + 1) ;
++i) if ( __isctype(( i ), 0x00010000L ) ) bitset_set (sbcset,
trans[i]); } else { for (i = 0; i < (0xff + 1) ; ++i) if
( __isctype(( i ), 0x00010000L ) ) bitset_set (sbcset, i); } }
while (0) ;
> else
> return _REG_ECTYPE ;
>
> return _REG_NOERROR ;
> }
>
> static bin_tree_t *
> build_charclass_op (re_dfa_t *dfa, unsigned char * trans,
> const unsigned char *class_name,
> const unsigned char *extra, _Bool non_match,
> reg_errcode_t *err)
> {
> re_bitset_ptr_t sbcset;
>
>
>
>
> reg_errcode_t ret;
> re_token_t br_token;
> bin_tree_t *tree;
>
> sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
>
>
>
>
>
>
>
> if (( sbcset == 0 ) )
>
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
>
> if (non_match)
> {
>
>
>
>
>
>
>
> }
>
>
> ret = build_charclass (trans, sbcset,
>
>
>
> class_name, 0);
>
> if (( ret != _REG_NOERROR ) )
> {
> free ( sbcset ) ;
>
>
>
> *err = ret;
> return 0 ;
> }
>
> for (; *extra; extra++)
> bitset_set (sbcset, *extra);
>
>
> if (non_match)
> bitset_not (sbcset);
>
>
>
>
>
>
>
>
> br_token.type = SIMPLE_BRACKET;
> br_token.opr.sbcset = sbcset;
> tree = create_token_tree (dfa, 0 , 0 , &br_token);
> if (( tree == 0 ) )
> goto build_word_op_espace;
>
> # 3672 "regcomp.c"
>
> return tree;
>
>
> build_word_op_espace:
> free ( sbcset ) ;
>
>
>
> *err = _REG_ESPACE ;
> return 0 ;
> }
>
>
>
>
>
>
> static Idx
> fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
> {
> Idx num = ((Idx) -1) ;
> unsigned char c;
> while (1)
> {
> fetch_token (token, input, syntax);
> c = token->opr.c;
> if (( token->type == END_OF_RE ) )
> return ((Idx) -2) ;
> if (token->type == OP_CLOSE_DUP_NUM || c == ',')
> break;
> num = ((token->type != CHARACTER || c < '0' || '9' < c
> || num == ((Idx) -2) )
> ? ((Idx) -2)
> : ((num == ((Idx) -1) ) ? c - '0' : num * 10 + c - '0'));
> num = (num > (0x7fff) ) ? ((Idx) -2) : num;
> }
> return num;
> }
>
> # 3726 "regcomp.c"
>
>
>
>
>
>
> static bin_tree_t *
> create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
> re_token_type_t type)
> {
> re_token_t t;
> t.type = type;
> return create_token_tree (dfa, left, right, &t);
> }
>
> static bin_tree_t *
> create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
> const re_token_t *token)
> {
> bin_tree_t *tree;
> if (( dfa->str_tree_storage_idx == ((1024 - sizeof (void *)) / sizeof
(bin_tree_t)) ) )
> {
> bin_tree_storage_t *storage = (( bin_tree_storage_t *) malloc
(( 1 ) * sizeof ( bin_tree_storage_t ))) ;
>
> if (storage == 0 )
> return 0 ;
> storage->next = dfa->str_tree_storage;
> dfa->str_tree_storage = storage;
> dfa->str_tree_storage_idx = 0;
> }
> tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++];
>
> tree->parent = 0 ;
> tree->left = left;
> tree->right = right;
> tree->token = *token;
> tree->token.duplicated = 0;
> tree->token.opt_subexp = 0;
> tree->first = 0 ;
> tree->next = 0 ;
> tree->node_idx = ((Idx) -1) ;
>
> if (left != 0 )
> left->parent = tree;
> if (right != 0 )
> right->parent = tree;
> return tree;
> }
>
>
>
>
> static reg_errcode_t
> mark_opt_subexp (void *extra, bin_tree_t *node)
> {
> Idx idx = (Idx) (long) extra;
> if (node->token.type == SUBEXP && node->token.opr.idx == idx)
> node->token.opt_subexp = 1;
>
> return _REG_NOERROR ;
> }
>
>
>
> static void
> free_token (re_token_t *node)
> {
>
>
>
>
>
> if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
> free ( node->opr.sbcset ) ;
> }
>
>
>
>
> static reg_errcode_t
> free_tree (void *extra, bin_tree_t *node)
> {
> free_token (&node->token);
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
>
> static bin_tree_t *
> duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa)
> {
> const bin_tree_t *node;
> bin_tree_t *dup_root;
> bin_tree_t **p_new = &dup_root, *dup_node = root->parent;
>
> for (node = root; ; )
> {
>
> *p_new = create_token_tree (dfa, 0 , 0 , &node->token);
> if (*p_new == 0 )
> return 0 ;
> (*p_new)->parent = dup_node;
> (*p_new)->token.duplicated = 1;
> dup_node = *p_new;
>
>
> if (node->left)
> {
> node = node->left;
> p_new = &dup_node->left;
> }
> else
> {
> const bin_tree_t *prev = 0 ;
> while (node->right == prev || node->right == 0 )
> {
> prev = node;
> node = node->parent;
> dup_node = dup_node->parent;
> if (!node)
> return dup_root;
> }
> node = node->right;
> p_new = &dup_node->right;
> }
> }
> }
> # 63 "regex.c" 2
>
> # 1 "regexec.c" 1
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
> Idx n) ;
> static void match_ctx_clean (re_match_context_t *mctx) ;
> static void match_ctx_free (re_match_context_t *cache) ;
> static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache,
Idx node,
> Idx str_idx, Idx from, Idx to)
> ;
> static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx
str_idx)
> ;
> static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx,
Idx node,
> Idx str_idx) ;
> static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t
*subtop,
> Idx node, Idx str_idx)
> ;
> static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t
**sifted_sts,
> re_dfastate_t **limited_sts, Idx last_node,
> Idx last_str_idx)
> ;
> static reg_errcode_t re_search_internal (const regex_t *preg,
> const char *string, Idx length,
> Idx start, Idx last_start, Idx stop,
> size_t nmatch, regmatch_t pmatch[],
> int eflags) ;
> static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp,
> const char *string1, Idx length1,
> const char *string2, Idx length2,
> Idx start, regoff_t range,
> struct re_registers *regs,
> Idx stop, _Bool ret_len) ;
> static regoff_t re_search_stub (struct re_pattern_buffer *bufp,
> const char *string, Idx length, Idx start,
> regoff_t range, Idx stop,
> struct re_registers *regs,
> _Bool ret_len) ;
> static unsigned int re_copy_regs (struct re_registers *regs, regmatch_t
*pmatch,
> Idx nregs, int regs_allocated)
> ;
> static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
> ;
> static Idx check_matching (re_match_context_t *mctx, _Bool
fl_longest_match,
> Idx *p_match_first) ;
> static Idx check_halt_state_context (const re_match_context_t *mctx,
> const re_dfastate_t *state, Idx idx)
> ;
> static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
> regmatch_t *prev_idx_match, Idx cur_node,
> Idx cur_idx, Idx nmatch) ;
> static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
> Idx str_idx, Idx dest_node, Idx nregs,
> regmatch_t *regs,
> re_node_set *eps_via_nodes)
> ;
> static reg_errcode_t set_regs (const regex_t *preg,
> const re_match_context_t *mctx,
> size_t nmatch, regmatch_t *pmatch,
> _Bool fl_backtrack) ;
> static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs)
> ;
>
>
>
>
>
>
>
> static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
> re_sift_context_t *sctx)
> ;
> static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
> re_sift_context_t *sctx, Idx str_idx,
> re_node_set *cur_dest)
> ;
> static reg_errcode_t update_cur_sifted_state (const re_match_context_t
*mctx,
> re_sift_context_t *sctx,
> Idx str_idx,
> re_node_set *dest_nodes)
> ;
> static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa,
> re_node_set *dest_nodes,
> const re_node_set *candidates)
> ;
> static _Bool check_dst_limits (const re_match_context_t *mctx,
> const re_node_set *limits,
> Idx dst_node, Idx dst_idx, Idx src_node,
> Idx src_idx) ;
> static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
> int boundaries, Idx subexp_idx,
> Idx from_node, Idx bkref_idx)
> ;
> static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
> Idx limit, Idx subexp_idx,
> Idx node, Idx str_idx,
> Idx bkref_idx) ;
> static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa,
> re_node_set *dest_nodes,
> const re_node_set *candidates,
> re_node_set *limits,
> struct re_backref_cache_entry *bkref_ents,
> Idx str_idx) ;
> static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
> re_sift_context_t *sctx,
> Idx str_idx, const re_node_set *candidates)
> ;
> static reg_errcode_t merge_state_array (const re_dfa_t *dfa,
> re_dfastate_t **dst,
> re_dfastate_t **src, Idx num)
> ;
> static re_dfastate_t *find_recover_state (reg_errcode_t *err,
> re_match_context_t *mctx) ;
> static re_dfastate_t *transit_state (reg_errcode_t *err,
> re_match_context_t *mctx,
> re_dfastate_t *state) ;
> static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
> re_match_context_t *mctx,
> re_dfastate_t *next_state)
> ;
> static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
> re_node_set *cur_nodes,
> Idx str_idx) ;
>
>
>
>
>
>
>
>
>
>
>
> static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
> const re_node_set *nodes)
> ;
> static reg_errcode_t get_subexp (re_match_context_t *mctx,
> Idx bkref_node, Idx bkref_str_idx)
> ;
> static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
> const re_sub_match_top_t *sub_top,
> re_sub_match_last_t *sub_last,
> Idx bkref_node, Idx bkref_str)
> ;
> static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
> Idx subexp_idx, int type) ;
> static reg_errcode_t check_arrival (re_match_context_t *mctx,
> state_array_t *path, Idx top_node,
> Idx top_str, Idx last_node, Idx last_str,
> int type) ;
> static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t
*mctx,
> Idx str_idx,
> re_node_set *cur_nodes,
> re_node_set *next_nodes)
> ;
> static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa,
> re_node_set *cur_nodes,
> Idx ex_subexp, int type)
> ;
> static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa,
> re_node_set *dst_nodes,
> Idx target, Idx ex_subexp,
> int type) ;
> static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
> re_node_set *cur_nodes, Idx cur_str,
> Idx subexp_num, int type)
> ;
> static _Bool build_trtable (const re_dfa_t *dfa,
> re_dfastate_t *state) ;
> # 195 "regexec.c"
>
> static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
> const re_dfastate_t *state,
> re_node_set *states_node,
> bitset_t *states_ch) ;
> static _Bool check_node_accept (const re_match_context_t *mctx,
> const re_token_t *node, Idx idx)
> ;
> static reg_errcode_t extend_buffers (re_match_context_t *mctx)
> ;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> int
> rpl_regexec (preg, string, nmatch, pmatch, eflags)
> const regex_t *__restrict preg;
> const char *__restrict string;
> size_t nmatch;
> regmatch_t pmatch[];
> int eflags;
> {
> reg_errcode_t err;
> Idx start, length;
>
>
>
>
> if (eflags & ~(1 | (1 << 1) | (1 << 2) ))
> return _REG_BADPAT ;
>
> if (eflags & (1 << 2) )
> {
> start = pmatch[0].rm_so;
> length = pmatch[0].rm_eo;
> }
> else
> {
> start = 0;
> length = strlen (string);
> }
>
> do { } while (0) ;
> if (preg->no_sub)
> err = re_search_internal (preg, string, length, start, length,
> length, 0, 0 , eflags);
> else
> err = re_search_internal (preg, string, length, start, length,
> length, nmatch, pmatch, eflags);
> do { } while (0) ;
> return err != _REG_NOERROR ;
> }
>
> # 279 "regexec.c"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> regoff_t
> rpl_re_match (bufp, string, length, start, regs)
> struct re_pattern_buffer *bufp;
> const char *string;
> Idx length, start;
> struct re_registers *regs;
> {
> return re_search_stub (bufp, string, length, start, 0, length, regs, 1 );
> }
>
>
>
>
> regoff_t
> rpl_re_search (bufp, string, length, start, range, regs)
> struct re_pattern_buffer *bufp;
> const char *string;
> Idx length, start;
> regoff_t range;
> struct re_registers *regs;
> {
> return re_search_stub (bufp, string, length, start, range, length, regs,
> 0 );
> }
>
>
>
>
> regoff_t
> rpl_re_match_2 (bufp, string1, length1, string2, length2, start, regs,
stop)
> struct re_pattern_buffer *bufp;
> const char *string1, *string2;
> Idx length1, length2, start, stop;
> struct re_registers *regs;
> {
> return re_search_2_stub (bufp, string1, length1, string2, length2,
> start, 0, regs, stop, 1 );
> }
>
>
>
>
> regoff_t
> rpl_re_search_2 (bufp, string1, length1, string2, length2, start,
range, regs, stop)
> struct re_pattern_buffer *bufp;
> const char *string1, *string2;
> Idx length1, length2, start, stop;
> regoff_t range;
> struct re_registers *regs;
> {
> return re_search_2_stub (bufp, string1, length1, string2, length2,
> start, range, regs, stop, 0 );
> }
>
>
>
>
> static regoff_t
>
> re_search_2_stub (struct re_pattern_buffer *bufp,
> const char *string1, Idx length1,
> const char *string2, Idx length2,
> Idx start, regoff_t range, struct re_registers *regs,
> Idx stop, _Bool ret_len)
> {
> const char *str;
> regoff_t rval;
> Idx len = length1 + length2;
> char *s = 0 ;
>
> if (( length1 < 0 || length2 < 0 || stop < 0 || len < length1 ) )
> return -2;
>
>
> if (length2 > 0)
> if (length1 > 0)
> {
> s = (( char *) malloc (( len ) * sizeof ( char ))) ;
>
> if (( s == 0 ) )
> return -2;
>
>
>
> memcpy (s, string1, length1);
> memcpy (s + length1, string2, length2);
>
> str = s;
> }
> else
> str = string2;
> else
> str = string1;
>
> rval = re_search_stub (bufp, str, len, start, range, stop, regs,
> ret_len);
> free ( s ) ;
> return rval;
> }
>
>
>
>
>
>
> static regoff_t
>
> re_search_stub (struct re_pattern_buffer *bufp,
> const char *string, Idx length,
> Idx start, regoff_t range, Idx stop, struct re_registers *regs,
> _Bool ret_len)
> {
> reg_errcode_t result;
> regmatch_t *pmatch;
> Idx nregs;
> regoff_t rval;
> int eflags = 0;
>
>
>
> Idx last_start = start + range;
>
>
> if (( start < 0 || start > length ) )
> return -1;
> if (( length < last_start || (0 <= range && last_start < start) ) )
> last_start = length;
> else if (( last_start < 0 || (range < 0 && start <= last_start) ) )
> last_start = 0;
>
> do { } while (0) ;
>
> eflags |= (bufp->not_bol) ? 1 : 0;
> eflags |= (bufp->not_eol) ? (1 << 1) : 0;
>
>
> if (start < last_start && bufp->fastmap != 0 && !bufp->fastmap_accurate)
> rpl_re_compile_fastmap (bufp);
>
> if (( bufp->no_sub ) )
> regs = 0 ;
>
>
> if (regs == 0 )
> nregs = 1;
> else if (( bufp->regs_allocated == 2
> && regs->num_regs <= bufp->re_nsub ) )
> {
> nregs = regs->num_regs;
> if (( nregs < 1 ) )
> {
>
> regs = 0 ;
> nregs = 1;
> }
> }
> else
> nregs = bufp->re_nsub + 1;
> pmatch = (( regmatch_t *) malloc (( nregs ) * sizeof ( regmatch_t ))) ;
> if (( pmatch == 0 ) )
> {
> rval = -2;
> goto out;
> }
>
> result = re_search_internal (bufp, string, length, start, last_start,
stop,
> nregs, pmatch, eflags);
>
> rval = 0;
>
>
> if (result != _REG_NOERROR )
> rval = -1;
> else if (regs != 0 )
> {
>
> bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
> bufp->regs_allocated);
> if (( bufp->regs_allocated == 0 ) )
> rval = -2;
> }
>
> if (( rval == 0 ) )
> {
> if (ret_len)
> {
> (( pmatch[0].rm_so == start ) ? (void)0 : __assert("regexec.c",
496, "pmatch[0].rm_so == start")) ;
> rval = pmatch[0].rm_eo - start;
> }
> else
> rval = pmatch[0].rm_so;
> }
> free ( pmatch ) ;
> out:
> do { } while (0) ;
> return rval;
> }
>
> static unsigned int
>
> re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
> int regs_allocated)
> {
> int rval = 1 ;
> Idx i;
> Idx need_regs = nregs + 1;
>
>
>
>
> if (regs_allocated == 0 )
> {
> regs->start = (( regoff_t *) malloc (( need_regs ) * sizeof (
regoff_t ))) ;
> if (( regs->start == 0 ) )
> return 0 ;
> regs->end = (( regoff_t *) malloc (( need_regs ) * sizeof (
regoff_t ))) ;
> if (( regs->end == 0 ) )
> {
> free ( regs->start ) ;
> return 0 ;
> }
> regs->num_regs = need_regs;
> }
> else if (regs_allocated == 1 )
> {
>
>
> if (( need_regs > regs->num_regs ) )
> {
> regoff_t *new_start = (( regoff_t *) realloc ( regs->start , (
need_regs ) * sizeof ( regoff_t ))) ;
> regoff_t *new_end;
> if (( new_start == 0 ) )
> return 0 ;
> new_end = (( regoff_t *) realloc ( regs->end , ( need_regs ) *
sizeof ( regoff_t ))) ;
> if (( new_end == 0 ) )
> {
> free ( new_start ) ;
> return 0 ;
> }
> regs->start = new_start;
> regs->end = new_end;
> regs->num_regs = need_regs;
> }
> }
> else
> {
> (( regs_allocated == 2 ) ? (void)0 : __assert("regexec.c", 556,
"regs_allocated == REGS_FIXED")) ;
>
> (( regs->num_regs >= nregs ) ? (void)0 : __assert("regexec.c",
558, "regs->num_regs >= nregs")) ;
> rval = 2 ;
> }
>
>
> for (i = 0; i < nregs; ++i)
> {
> regs->start[i] = pmatch[i].rm_so;
> regs->end[i] = pmatch[i].rm_eo;
> }
> for ( ; i < regs->num_regs; ++i)
> regs->start[i] = regs->end[i] = -1;
>
> return rval;
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> void
> rpl_re_set_registers (bufp, regs, num_regs, starts, ends)
> struct re_pattern_buffer *bufp;
> struct re_registers *regs;
> __re_size_t num_regs;
> regoff_t *starts, *ends;
> {
> if (num_regs)
> {
> bufp->regs_allocated = 1 ;
> regs->num_regs = num_regs;
> regs->start = starts;
> regs->end = ends;
> }
> else
> {
> bufp->regs_allocated = 0 ;
> regs->num_regs = 0;
> regs->start = regs->end = 0 ;
> }
> }
>
>
>
>
>
>
>
>
> int
>
>
>
> rpl_re_exec (s)
> const char *s;
> {
> return 0 == rpl_regexec (&re_comp_buf, s, 0, 0 , 0);
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
> static reg_errcode_t
>
> re_search_internal (const regex_t *preg,
> const char *string, Idx length,
> Idx start, Idx last_start, Idx stop,
> size_t nmatch, regmatch_t pmatch[],
> int eflags)
> {
> reg_errcode_t err;
> const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer;
> Idx left_lim, right_lim;
> int incr;
> _Bool fl_longest_match;
> int match_kind;
> Idx match_first;
> Idx match_last = ((Idx) -1) ;
> Idx extra_nmatch;
> _Bool sb;
> int ch;
>
>
>
> re_match_context_t mctx;
>
> char *fastmap = ((preg->fastmap != 0 && preg->fastmap_accurate
> && start != last_start && !preg->can_be_null)
> ? preg->fastmap : 0 );
> unsigned char * t = preg->translate;
>
>
> memset (&mctx, '\0', sizeof (re_match_context_t));
> mctx.dfa = dfa;
>
>
> extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub +
1) : 0;
> nmatch -= extra_nmatch;
>
>
> if (( preg->used == 0 || dfa->init_state == 0
> || dfa->init_state_word == 0 || dfa->init_state_nl == 0
> || dfa->init_state_begbuf == 0 ) )
> return _REG_NOMATCH ;
>
>
>
>
>
>
>
>
>
> if (dfa->init_state->nodes.nelem == 0
> && dfa->init_state_word->nodes.nelem == 0
> && (dfa->init_state_nl->nodes.nelem == 0
> || !preg->newline_anchor))
> {
> if (start != 0 && last_start != 0)
> return _REG_NOMATCH ;
> start = last_start = 0;
> }
>
>
> fl_longest_match = (nmatch != 0 || dfa->nbackref);
>
> err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len
+ 1,
> preg->translate, preg->syntax &
((((((((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) , dfa);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> mctx.input.stop = stop;
> mctx.input.raw_stop = stop;
> mctx.input.newline_anchor = preg->newline_anchor;
>
> err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
> if (( err != _REG_NOERROR ) )
> goto free_return;
>
>
>
>
>
> if (nmatch > 1 || dfa->has_mb_node)
> {
>
> if (( 4294967295U / sizeof (re_dfastate_t *) <=
mctx.input.bufs_len ) )
> {
> err = _REG_ESPACE ;
> goto free_return;
> }
>
> mctx.state_log = (( re_dfastate_t * *) malloc ((
mctx.input.bufs_len + 1 ) * sizeof ( re_dfastate_t * ))) ;
> if (( mctx.state_log == 0 ) )
> {
> err = _REG_ESPACE ;
> goto free_return;
> }
> }
> else
> mctx.state_log = 0 ;
>
> match_first = start;
> mctx.input.tip_context = (eflags & 1 ) ? ((1 << 1) << 1)
> : (1 << 1) | ((1 << 1) << 1) ;
>
>
> incr = (last_start < start) ? -1 : 1;
> left_lim = (last_start < start) ? last_start : start;
> right_lim = (last_start < start) ? start : last_start;
> sb = dfa->mb_cur_max == 1;
> match_kind =
> (fastmap
> ? ((sb || !(preg->syntax & ((((((((((((((((((((((((unsigned long
int) 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
1) << 1) << 1) || t) ? 4 : 0)
> | (start <= last_start ? 2 : 0)
> | (t != 0 ? 1 : 0))
> : 8);
>
> for (;; match_first += incr)
> {
> err = _REG_NOMATCH ;
> if (match_first < left_lim || right_lim < match_first)
> goto free_return;
>
>
>
>
>
>
> switch (match_kind)
> {
> case 8:
>
> break;
>
> case 7:
>
> while (( match_first < right_lim )
> && !fastmap[t[(unsigned char) string[match_first]]])
> ++match_first;
> goto forward_match_found_start_or_reached_end;
>
> case 6:
>
> while (( match_first < right_lim )
> && !fastmap[(unsigned char) string[match_first]])
> ++match_first;
>
> forward_match_found_start_or_reached_end:
> if (( match_first == right_lim ) )
> {
> ch = match_first >= length
> ? 0 : (unsigned char) string[match_first];
> if (!fastmap[t ? t[ch] : ch])
> goto free_return;
> }
> break;
>
> case 4:
> case 5:
>
> while (match_first >= left_lim)
> {
> ch = match_first >= length
> ? 0 : (unsigned char) string[match_first];
> if (fastmap[t ? t[ch] : ch])
> break;
> --match_first;
> }
> if (match_first < left_lim)
> goto free_return;
> break;
>
> default:
>
>
>
> for (;;)
> {
>
>
> __re_size_t offset = match_first - mctx.input.raw_mbs_idx;
> if (( offset >= (__re_size_t) mctx.input.valid_raw_len ) )
> {
> err = re_string_reconstruct (&mctx.input, match_first,
> eflags);
> if (( err != _REG_NOERROR ) )
> goto free_return;
>
> offset = match_first - mctx.input.raw_mbs_idx;
> }
>
>
> ch = (match_first >= length
> ? 0 : (( &mctx.input )->mbs[ offset ]) );
> if (fastmap[ch])
> break;
> match_first += incr;
> if (match_first < left_lim || match_first > right_lim)
> {
> err = _REG_NOMATCH ;
> goto free_return;
> }
> }
> break;
> }
>
>
>
> err = re_string_reconstruct (&mctx.input, match_first, eflags);
> if (( err != _REG_NOERROR ) )
> goto free_return;
>
>
>
>
>
>
>
>
>
>
> mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
> match_last = check_matching (&mctx, fl_longest_match,
> start <= last_start ? &match_first : 0 );
> if (match_last != ((Idx) -1) )
> {
> if (( match_last == ((Idx) -2) ) )
> {
> err = _REG_ESPACE ;
> goto free_return;
> }
> else
> {
> mctx.match_last = match_last;
> if ((!preg->no_sub && nmatch > 1) || dfa->nbackref)
> {
> re_dfastate_t *pstate = mctx.state_log[match_last];
> mctx.last_node = check_halt_state_context (&mctx, pstate,
> match_last);
> }
> if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match)
> || dfa->nbackref)
> {
> err = prune_impossible_nodes (&mctx);
> if (err == _REG_NOERROR )
> break;
> if (( err != _REG_NOMATCH ) )
> goto free_return;
> match_last = ((Idx) -1) ;
> }
> else
> break;
> }
> }
>
> match_ctx_clean (&mctx);
> }
>
>
>
>
>
>
>
> if (nmatch > 0)
> {
> Idx reg_idx;
>
>
> for (reg_idx = 1; reg_idx < nmatch; ++reg_idx)
> pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1;
>
>
> pmatch[0].rm_so = 0;
> pmatch[0].rm_eo = mctx.match_last;
>
>
>
>
> if (!preg->no_sub && nmatch > 1)
> {
> err = set_regs (preg, &mctx, nmatch, pmatch,
> dfa->has_plural_match && dfa->nbackref > 0);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> }
>
>
>
>
> for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
> if (pmatch[reg_idx].rm_so != -1)
> {
> # 941 "regexec.c"
>
> (( mctx.input.offsets_needed == 0 ) ? (void)0 :
__assert("regexec.c", 942, "mctx.input.offsets_needed == 0")) ;
>
> pmatch[reg_idx].rm_so += match_first;
> pmatch[reg_idx].rm_eo += match_first;
> }
> for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx)
> {
> pmatch[nmatch + reg_idx].rm_so = -1;
> pmatch[nmatch + reg_idx].rm_eo = -1;
> }
>
> if (dfa->subexp_map)
> for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++)
> if (dfa->subexp_map[reg_idx] != reg_idx)
> {
> pmatch[reg_idx + 1].rm_so
> = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so;
> pmatch[reg_idx + 1].rm_eo
> = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo;
> }
> }
>
> free_return:
> free ( mctx.state_log ) ;
> if (dfa->nbackref)
> match_ctx_free (&mctx);
> re_string_destruct (&mctx.input);
> return err;
> }
>
> static reg_errcode_t
>
> prune_impossible_nodes (re_match_context_t *mctx)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> Idx halt_node, match_last;
> reg_errcode_t ret;
> re_dfastate_t **sifted_states;
> re_dfastate_t **lim_states = 0 ;
> re_sift_context_t sctx;
>
>
>
> match_last = mctx->match_last;
> halt_node = mctx->last_node;
>
>
> if (( 4294967295U / sizeof (re_dfastate_t *) <= match_last ) )
> return _REG_ESPACE ;
>
> sifted_states = (( re_dfastate_t * *) malloc (( match_last + 1 ) *
sizeof ( re_dfastate_t * ))) ;
> if (( sifted_states == 0 ) )
> {
> ret = _REG_ESPACE ;
> goto free_return;
> }
> if (dfa->nbackref)
> {
> lim_states = (( re_dfastate_t * *) malloc (( match_last + 1 ) *
sizeof ( re_dfastate_t * ))) ;
> if (( lim_states == 0 ) )
> {
> ret = _REG_ESPACE ;
> goto free_return;
> }
> while (1)
> {
> memset (lim_states, '\0',
> sizeof (re_dfastate_t *) * (match_last + 1));
> sift_ctx_init (&sctx, sifted_states, lim_states, halt_node,
> match_last);
> ret = sift_states_backward (mctx, &sctx);
> free ( ( &sctx.limits )->elems ) ;
> if (( ret != _REG_NOERROR ) )
> goto free_return;
> if (sifted_states[0] != 0 || lim_states[0] != 0 )
> break;
> do
> {
> --match_last;
> if (! ((Idx) ( match_last ) < ((Idx) -2) ) )
> {
> ret = _REG_NOMATCH ;
> goto free_return;
> }
> } while (mctx->state_log[match_last] == 0
> || !mctx->state_log[match_last]->halt);
> halt_node = check_halt_state_context (mctx,
> mctx->state_log[match_last],
> match_last);
> }
> ret = merge_state_array (dfa, sifted_states, lim_states,
> match_last + 1);
> free ( lim_states ) ;
> lim_states = 0 ;
> if (( ret != _REG_NOERROR ) )
> goto free_return;
> }
> else
> {
> sift_ctx_init (&sctx, sifted_states, lim_states, halt_node,
match_last);
> ret = sift_states_backward (mctx, &sctx);
> free ( ( &sctx.limits )->elems ) ;
> if (( ret != _REG_NOERROR ) )
> goto free_return;
> }
> free ( mctx->state_log ) ;
> mctx->state_log = sifted_states;
> sifted_states = 0 ;
> mctx->last_node = halt_node;
> mctx->match_last = match_last;
> ret = _REG_NOERROR ;
> free_return:
> free ( sifted_states ) ;
> free ( lim_states ) ;
> return ret;
> }
>
>
>
>
>
> static inline re_dfastate_t *
>
> acquire_init_state_context (reg_errcode_t *err, const
re_match_context_t *mctx,
> Idx idx)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> if (dfa->init_state->has_constraint)
> {
> unsigned int context;
> context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags);
> if ((( context ) & 1 ) )
> return dfa->init_state_word;
> else if ((( context ) == 0) )
> return dfa->init_state;
> else if ((( context ) & ((1 << 1) << 1) ) && (( context ) &
(1 << 1) ) )
> return dfa->init_state_begbuf;
> else if ((( context ) & (1 << 1) ) )
> return dfa->init_state_nl;
> else if ((( context ) & ((1 << 1) << 1) ) )
> {
>
> return re_acquire_state_context (err, dfa,
> dfa->init_state->entrance_nodes,
> context);
> }
> else
>
> return dfa->init_state;
> }
> else
> return dfa->init_state;
> }
>
>
>
>
>
>
>
>
>
>
> static Idx
>
> check_matching (re_match_context_t *mctx, _Bool fl_longest_match,
> Idx *p_match_first)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> reg_errcode_t err;
> Idx match = 0;
> Idx match_last = ((Idx) -1) ;
> Idx cur_str_idx = (( &mctx->input )->cur_idx) ;
> re_dfastate_t *cur_state;
> _Bool at_init_state = p_match_first != 0 ;
> Idx next_start_idx = cur_str_idx;
>
> err = _REG_NOERROR ;
> cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
>
> if (( cur_state == 0 ) )
> {
> (( err == _REG_ESPACE ) ? (void)0 : __assert("regexec.c", 1124,
"err == REG_ESPACE")) ;
> return ((Idx) -2) ;
> }
>
> if (mctx->state_log != 0 )
> {
> mctx->state_log[cur_str_idx] = cur_state;
>
>
>
> if (( dfa->nbackref ) )
> {
> at_init_state = 0 ;
> err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
> if (( err != _REG_NOERROR ) )
> return err;
>
> if (cur_state->has_backref)
> {
> err = transit_state_bkref (mctx, &cur_state->nodes);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> }
> }
>
>
> if (( cur_state->halt ) )
> {
> if (!cur_state->has_constraint
> || check_halt_state_context (mctx, cur_state, cur_str_idx))
> {
> if (!fl_longest_match)
> return cur_str_idx;
> else
> {
> match_last = cur_str_idx;
> match = 1;
> }
> }
> }
>
> while (! (( &mctx->input )->stop <= ( &mctx->input )->cur_idx) )
> {
> re_dfastate_t *old_state = cur_state;
> Idx next_char_idx = (( &mctx->input )->cur_idx) + 1;
>
> if (( next_char_idx >= mctx->input.bufs_len )
> || (( next_char_idx >= mctx->input.valid_len )
> && mctx->input.valid_len < mctx->input.len))
> {
> err = extend_buffers (mctx);
> if (( err != _REG_NOERROR ) )
> {
> (( err == _REG_ESPACE ) ? (void)0 : __assert("regexec.c",
1178, "err == REG_ESPACE")) ;
> return ((Idx) -2) ;
> }
> }
>
> cur_state = transit_state (&err, mctx, cur_state);
> if (mctx->state_log != 0 )
> cur_state = merge_state_with_log (&err, mctx, cur_state);
>
> if (cur_state == 0 )
> {
>
>
>
> if (( err != _REG_NOERROR ) )
> return ((Idx) -2) ;
>
> if (mctx->state_log == 0
> || (match && !fl_longest_match)
> || (cur_state = find_recover_state (&err, mctx)) == 0 )
> break;
> }
>
> if (( at_init_state ) )
> {
> if (old_state == cur_state)
> next_start_idx = next_char_idx;
> else
> at_init_state = 0 ;
> }
>
> if (cur_state->halt)
> {
>
>
> if (!cur_state->has_constraint
> || check_halt_state_context (mctx, cur_state,
> (( &mctx->input )->cur_idx) ))
> {
>
> match_last = (( &mctx->input )->cur_idx) ;
> match = 1;
>
>
> p_match_first = 0 ;
> if (!fl_longest_match)
> break;
> }
> }
> }
>
> if (p_match_first)
> *p_match_first += next_start_idx;
>
> return match_last;
> }
>
>
>
> static _Bool
>
> check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int
context)
> {
> re_token_type_t type = dfa->nodes[node].type;
> unsigned int constraint = dfa->nodes[node].constraint;
> if (type != END_OF_RE)
> return 0 ;
> if (!constraint)
> return 1 ;
> if ((((( constraint ) & 0x0004 ) && ! (( context ) & 1 ) ) || (((
constraint ) & 0x0008 ) && (( context ) & 1 ) ) || ((( constraint ) &
0x0020 ) && ! (( context ) & (1 << 1) ) ) || ((( constraint ) &
0x0080 ) && ! (( context ) & (((1 << 1) << 1) << 1) ) )) )
> return 0 ;
> return 1 ;
> }
>
>
>
>
>
> static Idx
>
> check_halt_state_context (const re_match_context_t *mctx,
> const re_dfastate_t *state, Idx idx)
> {
> Idx i;
> unsigned int context;
>
>
>
> context = re_string_context_at (&mctx->input, idx, mctx->eflags);
> for (i = 0; i < state->nodes.nelem; ++i)
> if (check_halt_node_context (mctx->dfa, state->nodes.elems[i],
context))
> return state->nodes.elems[i];
> return 0;
> }
>
>
>
>
>
>
> static Idx
>
> proceed_next_node (const re_match_context_t *mctx, Idx nregs,
regmatch_t *regs,
> Idx *pidx, Idx node, re_node_set *eps_via_nodes,
> struct re_fail_stack_t *fs)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> Idx i;
> _Bool ok;
> if ((( dfa->nodes[node].type ) & 8 ) )
> {
> re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
> re_node_set *edests = &dfa->edests[node];
> Idx dest_node;
> ok = re_node_set_insert (eps_via_nodes, node);
> if (( ! ok ) )
> return ((Idx) -2) ;
>
>
> for (dest_node = ((Idx) -1) , i = 0; i < edests->nelem; ++i)
> {
> Idx candidate = edests->elems[i];
> if (!re_node_set_contains (cur_nodes, candidate))
> continue;
> if (dest_node == ((Idx) -1) )
> dest_node = candidate;
>
> else
> {
>
>
> if (re_node_set_contains (eps_via_nodes, dest_node))
> return candidate;
>
>
> else if (fs != 0
> && push_fail_stack (fs, *pidx, candidate, nregs, regs,
> eps_via_nodes))
> return ((Idx) -2) ;
>
>
> break;
> }
> }
> return dest_node;
> }
> else
> {
> Idx naccepted = 0;
> re_token_type_t type = dfa->nodes[node].type;
>
>
>
>
>
>
> if (type == OP_BACK_REF)
> {
> Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
> naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
> if (fs != 0 )
> {
> if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1)
> return ((Idx) -1) ;
> else if (naccepted)
> {
> char *buf = (char *) (( &mctx->input )->mbs) ;
> if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
> naccepted) != 0)
> return ((Idx) -1) ;
> }
> }
>
> if (naccepted == 0)
> {
> Idx dest_node;
> ok = re_node_set_insert (eps_via_nodes, node);
> if (( ! ok ) )
> return ((Idx) -2) ;
> dest_node = dfa->edests[node].elems[0];
> if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
> dest_node))
> return dest_node;
> }
> }
>
> if (naccepted != 0
> || check_node_accept (mctx, dfa->nodes + node, *pidx))
> {
> Idx dest_node = dfa->nexts[node];
> *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted;
> if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == 0
> || !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
> dest_node)))
> return ((Idx) -1) ;
> (( eps_via_nodes )->nelem = 0) ;
> return dest_node;
> }
> }
> return ((Idx) -1) ;
> }
>
> static reg_errcode_t
>
> push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
> Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
> {
> reg_errcode_t err;
> Idx num = fs->num++;
> if (fs->num == fs->alloc)
> {
> struct re_fail_stack_ent_t *new_array;
> new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t)
> * fs->alloc * 2));
> if (new_array == 0 )
> return _REG_ESPACE ;
> fs->alloc *= 2;
> fs->stack = new_array;
> }
> fs->stack[num].idx = str_idx;
> fs->stack[num].node = dest_node;
> fs->stack[num].regs = (( regmatch_t *) malloc (( nregs ) * sizeof (
regmatch_t ))) ;
> if (fs->stack[num].regs == 0 )
> return _REG_ESPACE ;
> memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
> err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes,
eps_via_nodes);
> return err;
> }
>
> static Idx
>
> pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
> regmatch_t *regs, re_node_set *eps_via_nodes)
> {
> Idx num = --fs->num;
> (( ((Idx) ( num ) < ((Idx) -2) ) ) ? (void)0 : __assert("regexec.c",
1413, "REG_VALID_INDEX (num)")) ;
> *pidx = fs->stack[num].idx;
> memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
> free ( ( eps_via_nodes )->elems ) ;
> free ( fs->stack[num].regs ) ;
> *eps_via_nodes = fs->stack[num].eps_via_nodes;
> return fs->stack[num].node;
> }
>
>
>
>
>
>
> static reg_errcode_t
>
> set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t
nmatch,
> regmatch_t *pmatch, _Bool fl_backtrack)
> {
> const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer;
> Idx idx, cur_node;
> re_node_set eps_via_nodes;
> struct re_fail_stack_t *fs;
> struct re_fail_stack_t fs_body = { 0, 2, 0 };
> regmatch_t *prev_idx_match;
> _Bool prev_idx_match_malloced = 0 ;
>
>
>
>
>
> if (fl_backtrack)
> {
> fs = &fs_body;
> fs->stack = (( struct re_fail_stack_ent_t *) malloc ((
fs->alloc ) * sizeof ( struct re_fail_stack_ent_t ))) ;
> if (fs->stack == 0 )
> return _REG_ESPACE ;
> }
> else
> fs = 0 ;
>
> cur_node = dfa->init_node;
> memset ( &eps_via_nodes , '\0', sizeof (re_node_set)) ;
>
> if ((( nmatch * sizeof (regmatch_t) ) < 4032) )
> prev_idx_match = (regmatch_t *) __builtin_alloca (nmatch * sizeof
(regmatch_t));
> else
> {
> prev_idx_match = (( regmatch_t *) malloc (( nmatch ) * sizeof (
regmatch_t ))) ;
> if (prev_idx_match == 0 )
> {
> free_fail_stack_return (fs);
> return _REG_ESPACE ;
> }
> prev_idx_match_malloced = 1 ;
> }
> memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
>
> for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
> {
> update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
>
> if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
> {
> Idx reg_idx;
> if (fs)
> {
> for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
> if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
> break;
> if (reg_idx == nmatch)
> {
> free ( ( &eps_via_nodes )->elems ) ;
> if (prev_idx_match_malloced)
> free ( prev_idx_match ) ;
> return free_fail_stack_return (fs);
> }
> cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
> &eps_via_nodes);
> }
> else
> {
> free ( ( &eps_via_nodes )->elems ) ;
> if (prev_idx_match_malloced)
> free ( prev_idx_match ) ;
> return _REG_NOERROR ;
> }
> }
>
>
> cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
> &eps_via_nodes, fs);
>
> if (( ! ((Idx) ( cur_node ) < ((Idx) -2) ) ) )
> {
> if (( cur_node == ((Idx) -2) ) )
> {
> free ( ( &eps_via_nodes )->elems ) ;
> if (prev_idx_match_malloced)
> free ( prev_idx_match ) ;
> free_fail_stack_return (fs);
> return _REG_ESPACE ;
> }
> if (fs)
> cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
> &eps_via_nodes);
> else
> {
> free ( ( &eps_via_nodes )->elems ) ;
> if (prev_idx_match_malloced)
> free ( prev_idx_match ) ;
> return _REG_NOMATCH ;
> }
> }
> }
> free ( ( &eps_via_nodes )->elems ) ;
> if (prev_idx_match_malloced)
> free ( prev_idx_match ) ;
> return free_fail_stack_return (fs);
> }
>
> static reg_errcode_t
>
> free_fail_stack_return (struct re_fail_stack_t *fs)
> {
> if (fs)
> {
> Idx fs_idx;
> for (fs_idx = 0; fs_idx < fs->num; ++fs_idx)
> {
> free ( ( &fs->stack[fs_idx].eps_via_nodes )->elems ) ;
> free ( fs->stack[fs_idx].regs ) ;
> }
> free ( fs->stack ) ;
> }
> return _REG_NOERROR ;
> }
>
> static void
>
> update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
> regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch)
> {
> int type = dfa->nodes[cur_node].type;
> if (type == OP_OPEN_SUBEXP)
> {
> Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
>
>
> if (reg_num < nmatch)
> {
> pmatch[reg_num].rm_so = cur_idx;
> pmatch[reg_num].rm_eo = -1;
> }
> }
> else if (type == OP_CLOSE_SUBEXP)
> {
> Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
> if (reg_num < nmatch)
> {
>
> if (pmatch[reg_num].rm_so < cur_idx)
> {
> pmatch[reg_num].rm_eo = cur_idx;
>
>
> memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
> }
> else
> {
> if (dfa->nodes[cur_node].opt_subexp
> && prev_idx_match[reg_num].rm_so != -1)
>
>
>
>
>
> memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch);
> else
>
>
> pmatch[reg_num].rm_eo = cur_idx;
> }
> }
> }
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> static reg_errcode_t
>
> sift_states_backward (const re_match_context_t *mctx, re_sift_context_t
*sctx)
> {
> reg_errcode_t err;
> int null_cnt = 0;
> Idx str_idx = sctx->last_str_idx;
> re_node_set cur_dest;
>
>
>
>
>
>
>
> err = re_node_set_init_1 (&cur_dest, sctx->last_node);
> if (( err != _REG_NOERROR ) )
> return err;
> err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
> if (( err != _REG_NOERROR ) )
> goto free_return;
>
>
> while (str_idx > 0)
> {
>
> null_cnt = (sctx->sifted_states[str_idx] == 0 ) ? null_cnt + 1 : 0;
> if (null_cnt > mctx->max_mb_elem_len)
> {
> memset (sctx->sifted_states, '\0',
> sizeof (re_dfastate_t *) * str_idx);
> free ( ( &cur_dest )->elems ) ;
> return _REG_NOERROR ;
> }
> (( &cur_dest )->nelem = 0) ;
> --str_idx;
>
> if (mctx->state_log[str_idx])
> {
> err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> }
>
>
>
>
>
> err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> }
> err = _REG_NOERROR ;
> free_return:
> free ( ( &cur_dest )->elems ) ;
> return err;
> }
>
> static reg_errcode_t
>
> build_sifted_states (const re_match_context_t *mctx, re_sift_context_t
*sctx,
> Idx str_idx, re_node_set *cur_dest)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes;
> Idx i;
>
>
>
>
>
>
>
>
> for (i = 0; i < cur_src->nelem; i++)
> {
> Idx prev_node = cur_src->elems[i];
> int naccepted = 0;
> _Bool ok;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> if (!naccepted
> && check_node_accept (mctx, dfa->nodes + prev_node, str_idx)
> && (( sctx->sifted_states[str_idx + 1] ) != 0 &&
re_node_set_contains (&( sctx->sifted_states[str_idx + 1] )->nodes,
> dfa->nexts[prev_node] )) )
> naccepted = 1;
>
> if (naccepted == 0)
> continue;
>
> if (sctx->limits.nelem)
> {
> Idx to_idx = str_idx + naccepted;
> if (check_dst_limits (mctx, &sctx->limits,
> dfa->nexts[prev_node], to_idx,
> prev_node, str_idx))
> continue;
> }
> ok = re_node_set_insert (cur_dest, prev_node);
> if (( ! ok ) )
> return _REG_ESPACE ;
> }
>
> return _REG_NOERROR ;
> }
>
>
>
> static reg_errcode_t
>
> clean_state_log_if_needed (re_match_context_t *mctx, Idx
next_state_log_idx)
> {
> Idx top = mctx->state_log_top;
>
> if (next_state_log_idx >= mctx->input.bufs_len
> || (next_state_log_idx >= mctx->input.valid_len
> && mctx->input.valid_len < mctx->input.len))
> {
> reg_errcode_t err;
> err = extend_buffers (mctx);
> if (( err != _REG_NOERROR ) )
> return err;
> }
>
> if (top < next_state_log_idx)
> {
> memset (mctx->state_log + top + 1, '\0',
> sizeof (re_dfastate_t *) * (next_state_log_idx - top));
> mctx->state_log_top = next_state_log_idx;
> }
> return _REG_NOERROR ;
> }
>
> static reg_errcode_t
>
> merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
> re_dfastate_t **src, Idx num)
> {
> Idx st_idx;
> reg_errcode_t err;
> for (st_idx = 0; st_idx < num; ++st_idx)
> {
> if (dst[st_idx] == 0 )
> dst[st_idx] = src[st_idx];
> else if (src[st_idx] != 0 )
> {
> re_node_set merged_set;
> err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
> &src[st_idx]->nodes);
> if (( err != _REG_NOERROR ) )
> return err;
> dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
> free ( ( &merged_set )->elems ) ;
> if (( err != _REG_NOERROR ) )
> return err;
> }
> }
> return _REG_NOERROR ;
> }
>
> static reg_errcode_t
>
> update_cur_sifted_state (const re_match_context_t *mctx,
> re_sift_context_t *sctx, Idx str_idx,
> re_node_set *dest_nodes)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> reg_errcode_t err = _REG_NOERROR ;
> const re_node_set *candidates;
> candidates = ((mctx->state_log[str_idx] == 0 ) ? 0
> : &mctx->state_log[str_idx]->nodes);
>
> if (dest_nodes->nelem == 0)
> sctx->sifted_states[str_idx] = 0 ;
> else
> {
> if (candidates)
> {
>
>
> err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
> if (( err != _REG_NOERROR ) )
> return err;
>
>
> if (sctx->limits.nelem)
> {
> err = check_subexp_limits (dfa, dest_nodes, candidates,
&sctx->limits,
> mctx->bkref_ents, str_idx);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> }
>
> sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa,
dest_nodes);
> if (( err != _REG_NOERROR ) )
> return err;
> }
>
> if (candidates && mctx->state_log[str_idx]->has_backref)
> {
> err = sift_states_bkref (mctx, sctx, str_idx, candidates);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> return _REG_NOERROR ;
> }
>
> static reg_errcode_t
>
> add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
> const re_node_set *candidates)
> {
> reg_errcode_t err = _REG_NOERROR ;
> Idx i;
>
> re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
> if (( err != _REG_NOERROR ) )
> return err;
>
> if (!state->inveclosure.alloc)
> {
> err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
> if (( err != _REG_NOERROR ) )
> return _REG_ESPACE ;
> for (i = 0; i < dest_nodes->nelem; i++)
> re_node_set_merge (&state->inveclosure,
> dfa->inveclosures + dest_nodes->elems[i]);
> }
> return re_node_set_add_intersect (dest_nodes, candidates,
> &state->inveclosure);
> }
>
> static reg_errcode_t
>
> sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set
*dest_nodes,
> const re_node_set *candidates)
> {
> Idx ecl_idx;
> reg_errcode_t err;
> re_node_set *inv_eclosure = dfa->inveclosures + node;
> re_node_set except_nodes;
> memset ( &except_nodes , '\0', sizeof (re_node_set)) ;
> for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
> {
> Idx cur_node = inv_eclosure->elems[ecl_idx];
> if (cur_node == node)
> continue;
> if ((( dfa->nodes[cur_node].type ) & 8 ) )
> {
> Idx edst1 = dfa->edests[cur_node].elems[0];
> Idx edst2 = ((dfa->edests[cur_node].nelem > 1)
> ? dfa->edests[cur_node].elems[1] : ((Idx) -1) );
> if ((!re_node_set_contains (inv_eclosure, edst1)
> && re_node_set_contains (dest_nodes, edst1))
> || (((Idx) (( edst2 ) - 1) < (Idx) (((Idx) -2) - 1))
> && !re_node_set_contains (inv_eclosure, edst2)
> && re_node_set_contains (dest_nodes, edst2)))
> {
> err = re_node_set_add_intersect (&except_nodes, candidates,
> dfa->inveclosures + cur_node);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &except_nodes )->elems ) ;
> return err;
> }
> }
> }
> }
> for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
> {
> Idx cur_node = inv_eclosure->elems[ecl_idx];
> if (!re_node_set_contains (&except_nodes, cur_node))
> {
> Idx idx = re_node_set_contains (dest_nodes, cur_node) - 1;
> re_node_set_remove_at (dest_nodes, idx);
> }
> }
> free ( ( &except_nodes )->elems ) ;
> return _REG_NOERROR ;
> }
>
> static _Bool
>
> check_dst_limits (const re_match_context_t *mctx, const re_node_set
*limits,
> Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> Idx lim_idx, src_pos, dst_pos;
>
> Idx dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx);
> Idx src_bkref_idx = search_cur_bkref_entry (mctx, src_idx);
> for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
> {
> Idx subexp_idx;
> struct re_backref_cache_entry *ent;
> ent = mctx->bkref_ents + limits->elems[lim_idx];
> subexp_idx = dfa->nodes[ent->node].opr.idx;
>
> dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
> subexp_idx, dst_node, dst_idx,
> dst_bkref_idx);
> src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
> subexp_idx, src_node, src_idx,
> src_bkref_idx);
>
>
>
>
>
> if (src_pos == dst_pos)
> continue;
> else
> return 1 ;
> }
> return 0 ;
> }
>
> static int
>
> check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int
boundaries,
> Idx subexp_idx, Idx from_node, Idx bkref_idx)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> const re_node_set *eclosures = dfa->eclosures + from_node;
> Idx node_idx;
>
>
>
> for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx)
> {
> Idx node = eclosures->elems[node_idx];
> switch (dfa->nodes[node].type)
> {
> case OP_BACK_REF:
> if (bkref_idx != ((Idx) -1) )
> {
> struct re_backref_cache_entry *ent = mctx->bkref_ents +
bkref_idx;
> do
> {
> Idx dst;
> int cpos;
>
> if (ent->node != node)
> continue;
>
> if (subexp_idx < 32
> && !(ent->eps_reachable_subexps_map
> & ((bitset_word_t) 1 << subexp_idx)))
> continue;
>
>
>
>
>
>
>
> dst = dfa->edests[node].elems[0];
> if (dst == from_node)
> {
> if (boundaries & 1)
> return -1;
> else
> return 0;
> }
>
> cpos =
> check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
> dst, bkref_idx);
> if (cpos == -1 )
> return -1;
> if (cpos == 0 && (boundaries & 2))
> return 0;
>
> if (subexp_idx < 32 )
> ent->eps_reachable_subexps_map
> &= ~((bitset_word_t) 1 << subexp_idx);
> }
> while (ent++->more);
> }
> break;
>
> case OP_OPEN_SUBEXP:
> if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx)
> return -1;
> break;
>
> case OP_CLOSE_SUBEXP:
> if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx)
> return 0;
> break;
>
> default:
> break;
> }
> }
>
> return (boundaries & 2) ? 1 : 0;
> }
>
> static int
>
> check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
> Idx subexp_idx, Idx from_node, Idx str_idx,
> Idx bkref_idx)
> {
> struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
> int boundaries;
>
>
> if (str_idx < lim->subexp_from)
> return -1;
>
> if (lim->subexp_to < str_idx)
> return 1;
>
>
> boundaries = (str_idx == lim->subexp_from);
> boundaries |= (str_idx == lim->subexp_to) << 1;
> if (boundaries == 0)
> return 0;
>
>
> return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
> from_node, bkref_idx);
> }
>
>
>
>
> static reg_errcode_t
>
> check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
> const re_node_set *candidates, re_node_set *limits,
> struct re_backref_cache_entry *bkref_ents, Idx str_idx)
> {
> reg_errcode_t err;
> Idx node_idx, lim_idx;
>
> for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
> {
> Idx subexp_idx;
> struct re_backref_cache_entry *ent;
> ent = bkref_ents + limits->elems[lim_idx];
>
> if (str_idx <= ent->subexp_from || ent->str_idx < str_idx)
> continue;
>
> subexp_idx = dfa->nodes[ent->node].opr.idx;
> if (ent->subexp_to == str_idx)
> {
> Idx ops_node = ((Idx) -1) ;
> Idx cls_node = ((Idx) -1) ;
> for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
> {
> Idx node = dest_nodes->elems[node_idx];
> re_token_type_t type = dfa->nodes[node].type;
> if (type == OP_OPEN_SUBEXP
> && subexp_idx == dfa->nodes[node].opr.idx)
> ops_node = node;
> else if (type == OP_CLOSE_SUBEXP
> && subexp_idx == dfa->nodes[node].opr.idx)
> cls_node = node;
> }
>
>
>
> if (((Idx) ( ops_node ) < ((Idx) -2) ) )
> {
> err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
> candidates);
> if (( err != _REG_NOERROR ) )
> return err;
> }
>
>
> if (((Idx) ( cls_node ) < ((Idx) -2) ) )
> for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
> {
> Idx node = dest_nodes->elems[node_idx];
> if (!re_node_set_contains (dfa->inveclosures + node,
> cls_node)
> && !re_node_set_contains (dfa->eclosures + node,
> cls_node))
> {
>
>
> err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
> candidates);
> if (( err != _REG_NOERROR ) )
> return err;
> --node_idx;
> }
> }
> }
> else
> {
> for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
> {
> Idx node = dest_nodes->elems[node_idx];
> re_token_type_t type = dfa->nodes[node].type;
> if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP)
> {
> if (subexp_idx != dfa->nodes[node].opr.idx)
> continue;
>
>
> err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
> candidates);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> }
> }
> }
> return _REG_NOERROR ;
> }
>
> static reg_errcode_t
>
> sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
> Idx str_idx, const re_node_set *candidates)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> reg_errcode_t err;
> Idx node_idx, node;
> re_sift_context_t local_sctx;
> Idx first_idx = search_cur_bkref_entry (mctx, str_idx);
>
> if (first_idx == ((Idx) -1) )
> return _REG_NOERROR ;
>
> local_sctx.sifted_states = 0 ;
>
> for (node_idx = 0; node_idx < candidates->nelem; ++node_idx)
> {
> Idx enabled_idx;
> re_token_type_t type;
> struct re_backref_cache_entry *entry;
> node = candidates->elems[node_idx];
> type = dfa->nodes[node].type;
>
> if (node == sctx->last_node && str_idx == sctx->last_str_idx)
> continue;
> if (type != OP_BACK_REF)
> continue;
>
> entry = mctx->bkref_ents + first_idx;
> enabled_idx = first_idx;
> do
> {
> Idx subexp_len;
> Idx to_idx;
> Idx dst_node;
> _Bool ok;
> re_dfastate_t *cur_state;
>
> if (entry->node != node)
> continue;
> subexp_len = entry->subexp_to - entry->subexp_from;
> to_idx = str_idx + subexp_len;
> dst_node = (subexp_len ? dfa->nexts[node]
> : dfa->edests[node].elems[0]);
>
> if (to_idx > sctx->last_str_idx
> || sctx->sifted_states[to_idx] == 0
> || ! (( sctx->sifted_states[to_idx] ) != 0 &&
re_node_set_contains (&( sctx->sifted_states[to_idx] )->nodes,
dst_node ))
> || check_dst_limits (mctx, &sctx->limits, node,
> str_idx, dst_node, to_idx))
> continue;
>
> if (local_sctx.sifted_states == 0 )
> {
> local_sctx = *sctx;
> err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> }
> local_sctx.last_node = node;
> local_sctx.last_str_idx = str_idx;
> ok = re_node_set_insert (&local_sctx.limits, enabled_idx);
> if (( ! ok ) )
> {
> err = _REG_ESPACE ;
> goto free_return;
> }
> cur_state = local_sctx.sifted_states[str_idx];
> err = sift_states_backward (mctx, &local_sctx);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> if (sctx->limited_states != 0 )
> {
> err = merge_state_array (dfa, sctx->limited_states,
> local_sctx.sifted_states,
> str_idx + 1);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> }
> local_sctx.sifted_states[str_idx] = cur_state;
> (re_node_set_remove_at ( &local_sctx.limits ,
re_node_set_contains ( &local_sctx.limits , enabled_idx ) - 1)) ;
>
>
> entry = mctx->bkref_ents + enabled_idx;
> }
> while (enabled_idx++, entry++->more);
> }
> err = _REG_NOERROR ;
> free_return:
> if (local_sctx.sifted_states != 0 )
> {
> free ( ( &local_sctx.limits )->elems ) ;
> }
>
> return err;
> }
>
>
> # 2273 "regexec.c"
>
>
>
>
>
>
>
>
>
>
> static re_dfastate_t *
>
> transit_state (reg_errcode_t *err, re_match_context_t *mctx,
> re_dfastate_t *state)
> {
> re_dfastate_t **trtable;
> unsigned char ch;
>
> # 2299 "regexec.c"
>
>
>
>
>
>
>
>
>
>
> ch = (( &mctx->input )->mbs[( &mctx->input )->cur_idx++]) ;
> for (;;)
> {
> trtable = state->trtable;
> if (( trtable != 0 ) )
> return trtable[ch];
>
> trtable = state->word_trtable;
> if (( trtable != 0 ) )
> {
> unsigned int context;
> context
> = re_string_context_at (&mctx->input,
> (( &mctx->input )->cur_idx) - 1,
> mctx->eflags);
> if ((( context ) & 1 ) )
> return trtable[ch + (0xff + 1) ];
> else
> return trtable[ch];
> }
>
> if (!build_trtable (mctx->dfa, state))
> {
> *err = _REG_ESPACE ;
> return 0 ;
> }
>
>
> }
> }
>
>
> re_dfastate_t *
>
> merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
> re_dfastate_t *next_state)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> Idx cur_idx = (( &mctx->input )->cur_idx) ;
>
> if (cur_idx > mctx->state_log_top)
> {
> mctx->state_log[cur_idx] = next_state;
> mctx->state_log_top = cur_idx;
> }
> else if (mctx->state_log[cur_idx] == 0)
> {
> mctx->state_log[cur_idx] = next_state;
> }
> else
> {
> re_dfastate_t *pstate;
> unsigned int context;
> re_node_set next_nodes, *log_nodes, *table_nodes = 0 ;
>
>
>
>
> pstate = mctx->state_log[cur_idx];
> log_nodes = pstate->entrance_nodes;
> if (next_state != 0 )
> {
> table_nodes = next_state->entrance_nodes;
> *err = re_node_set_init_union (&next_nodes, table_nodes,
> log_nodes);
> if (( *err != _REG_NOERROR ) )
> return 0 ;
> }
> else
> next_nodes = *log_nodes;
>
>
>
> context = re_string_context_at (&mctx->input,
> (( &mctx->input )->cur_idx) - 1,
> mctx->eflags);
> next_state = mctx->state_log[cur_idx]
> = re_acquire_state_context (err, dfa, &next_nodes, context);
>
>
>
> if (table_nodes != 0 )
> free ( ( &next_nodes )->elems ) ;
> }
>
> if (( dfa->nbackref ) && next_state != 0 )
> {
>
>
>
> *err = check_subexp_matching_top (mctx, &next_state->nodes,
> cur_idx);
> if (( *err != _REG_NOERROR ) )
> return 0 ;
>
>
> if (next_state->has_backref)
> {
> *err = transit_state_bkref (mctx, &next_state->nodes);
> if (( *err != _REG_NOERROR ) )
> return 0 ;
> next_state = mctx->state_log[cur_idx];
> }
> }
>
> return next_state;
> }
>
>
>
>
> static re_dfastate_t *
>
> find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
> {
> re_dfastate_t *cur_state;
> do
> {
> Idx max = mctx->state_log_top;
> Idx cur_str_idx = (( &mctx->input )->cur_idx) ;
>
> do
> {
> if (++cur_str_idx > max)
> return 0 ;
> (( &mctx->input )->cur_idx += ( 1 )) ;
> }
> while (mctx->state_log[cur_str_idx] == 0 );
>
> cur_state = merge_state_with_log (err, mctx, 0 );
> }
> while (*err == _REG_NOERROR && cur_state == 0 );
> return cur_state;
> }
>
>
>
>
>
>
>
>
> static reg_errcode_t
>
> check_subexp_matching_top (re_match_context_t *mctx, re_node_set
*cur_nodes,
> Idx str_idx)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> Idx node_idx;
> reg_errcode_t err;
>
>
>
>
>
>
> for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx)
> {
> Idx node = cur_nodes->elems[node_idx];
> if (dfa->nodes[node].type == OP_OPEN_SUBEXP
> && dfa->nodes[node].opr.idx < 32
> && (dfa->used_bkref_map
> & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
> {
> err = match_ctx_add_subtop (mctx, node, str_idx);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> }
> return _REG_NOERROR ;
> }
>
> # 2521 "regexec.c"
>
>
> # 2593 "regexec.c"
>
>
> static reg_errcode_t
>
> transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> reg_errcode_t err;
> Idx i;
> Idx cur_str_idx = (( &mctx->input )->cur_idx) ;
>
> for (i = 0; i < nodes->nelem; ++i)
> {
> Idx dest_str_idx, prev_nelem, bkc_idx;
> Idx node_idx = nodes->elems[i];
> unsigned int context;
> const re_token_t *node = dfa->nodes + node_idx;
> re_node_set *new_dest_nodes;
>
>
> if (node->type != OP_BACK_REF)
> continue;
>
> if (node->constraint)
> {
> context = re_string_context_at (&mctx->input, cur_str_idx,
> mctx->eflags);
> if ((((( node->constraint ) & 0x0004 ) && ! (( context ) & 1 )
) || ((( node->constraint ) & 0x0008 ) && (( context ) & 1 ) ) || (((
node->constraint ) & 0x0020 ) && ! (( context ) & (1 << 1) ) ) ||
((( node->constraint ) & 0x0080 ) && ! (( context ) & (((1 << 1) <<
1) << 1) ) )) )
> continue;
> }
>
>
>
> bkc_idx = mctx->nbkref_ents;
> err = get_subexp (mctx, node_idx, cur_str_idx);
> if (( err != _REG_NOERROR ) )
> goto free_return;
>
>
>
>
>
>
> for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
> {
> Idx subexp_len;
> re_dfastate_t *dest_state;
> struct re_backref_cache_entry *bkref_ent;
> bkref_ent = mctx->bkref_ents + bkc_idx;
> if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx)
> continue;
> subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from;
> new_dest_nodes = (subexp_len == 0
> ? dfa->eclosures + dfa->edests[node_idx].elems[0]
> : dfa->eclosures + dfa->nexts[node_idx]);
> dest_str_idx = (cur_str_idx + bkref_ent->subexp_to
> - bkref_ent->subexp_from);
> context = re_string_context_at (&mctx->input, dest_str_idx - 1,
> mctx->eflags);
> dest_state = mctx->state_log[dest_str_idx];
> prev_nelem = ((mctx->state_log[cur_str_idx] == 0 ) ? 0
> : mctx->state_log[cur_str_idx]->nodes.nelem);
>
> if (dest_state == 0 )
> {
> mctx->state_log[dest_str_idx]
> = re_acquire_state_context (&err, dfa, new_dest_nodes,
> context);
> if (( mctx->state_log[dest_str_idx] == 0
> && err != _REG_NOERROR ) )
> goto free_return;
> }
> else
> {
> re_node_set dest_nodes;
> err = re_node_set_init_union (&dest_nodes,
> dest_state->entrance_nodes,
> new_dest_nodes);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &dest_nodes )->elems ) ;
> goto free_return;
> }
> mctx->state_log[dest_str_idx]
> = re_acquire_state_context (&err, dfa, &dest_nodes, context);
> free ( ( &dest_nodes )->elems ) ;
> if (( mctx->state_log[dest_str_idx] == 0
> && err != _REG_NOERROR ) )
> goto free_return;
> }
>
>
> if (subexp_len == 0
> && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem)
> {
> err = check_subexp_matching_top (mctx, new_dest_nodes,
> cur_str_idx);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> err = transit_state_bkref (mctx, new_dest_nodes);
> if (( err != _REG_NOERROR ) )
> goto free_return;
> }
> }
> }
> err = _REG_NOERROR ;
> free_return:
> return err;
> }
>
>
>
>
>
>
>
> static reg_errcode_t
>
> get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> Idx subexp_num, sub_top_idx;
> const char *buf = (const char *) (( &mctx->input )->mbs) ;
>
> Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
> if (cache_idx != ((Idx) -1) )
> {
> const struct re_backref_cache_entry *entry
> = mctx->bkref_ents + cache_idx;
> do
> if (entry->node == bkref_node)
> return _REG_NOERROR ;
> while (entry++->more);
> }
>
> subexp_num = dfa->nodes[bkref_node].opr.idx;
>
>
> for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
> {
> reg_errcode_t err;
> re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx];
> re_sub_match_last_t *sub_last;
> Idx sub_last_idx, sl_str, bkref_str_off;
>
> if (dfa->nodes[sub_top->node].opr.idx != subexp_num)
> continue;
>
> sl_str = sub_top->str_idx;
> bkref_str_off = bkref_str_idx;
>
>
> for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts;
++sub_last_idx)
> {
> regoff_t sl_str_diff;
> sub_last = sub_top->lasts[sub_last_idx];
> sl_str_diff = sub_last->str_idx - sl_str;
>
>
> if (sl_str_diff > 0)
> {
> if (( bkref_str_off + sl_str_diff > mctx->input.valid_len ) )
> {
>
> if (bkref_str_off + sl_str_diff > mctx->input.len)
> break;
>
> err = clean_state_log_if_needed (mctx,
> bkref_str_off
> + sl_str_diff);
> if (( err != _REG_NOERROR ) )
> return err;
> buf = (const char *) (( &mctx->input )->mbs) ;
> }
> if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0)
>
> break;
> }
> bkref_str_off += sl_str_diff;
> sl_str += sl_str_diff;
> err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
> bkref_str_idx);
>
>
>
> buf = (const char *) (( &mctx->input )->mbs) ;
>
> if (err == _REG_NOMATCH )
> continue;
> if (( err != _REG_NOERROR ) )
> return err;
> }
>
> if (sub_last_idx < sub_top->nlasts)
> continue;
> if (sub_last_idx > 0)
> ++sl_str;
>
> for (; sl_str <= bkref_str_idx; ++sl_str)
> {
> Idx cls_node;
> regoff_t sl_str_off;
> const re_node_set *nodes;
> sl_str_off = sl_str - sub_top->str_idx;
>
>
> if (sl_str_off > 0)
> {
> if (( bkref_str_off >= mctx->input.valid_len ) )
> {
>
> if (bkref_str_off >= mctx->input.len)
> break;
>
> err = extend_buffers (mctx);
> if (( err != _REG_NOERROR ) )
> return err;
>
> buf = (const char *) (( &mctx->input )->mbs) ;
> }
> if (buf [bkref_str_off++] != buf[sl_str - 1])
> break;
>
> }
> if (mctx->state_log[sl_str] == 0 )
> continue;
>
> nodes = &mctx->state_log[sl_str]->nodes;
> cls_node = find_subexp_node (dfa, nodes, subexp_num,
> OP_CLOSE_SUBEXP);
> if (cls_node == ((Idx) -1) )
> continue;
> if (sub_top->path == 0 )
> {
> sub_top->path = calloc (sizeof (state_array_t),
> sl_str - sub_top->str_idx + 1);
> if (sub_top->path == 0 )
> return _REG_ESPACE ;
> }
>
>
> err = check_arrival (mctx, sub_top->path, sub_top->node,
> sub_top->str_idx, cls_node, sl_str,
> OP_CLOSE_SUBEXP);
> if (err == _REG_NOMATCH )
> continue;
> if (( err != _REG_NOERROR ) )
> return err;
> sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
> if (( sub_last == 0 ) )
> return _REG_ESPACE ;
> err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
> bkref_str_idx);
> if (err == _REG_NOMATCH )
> continue;
> }
> }
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
>
> static reg_errcode_t
>
> get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t
*sub_top,
> re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str)
> {
> reg_errcode_t err;
> Idx to_idx;
>
> err = check_arrival (mctx, &sub_last->path, sub_last->node,
> sub_last->str_idx, bkref_node, bkref_str,
> OP_OPEN_SUBEXP);
> if (err != _REG_NOERROR )
> return err;
> err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
> sub_last->str_idx);
> if (( err != _REG_NOERROR ) )
> return err;
> to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
> return clean_state_log_if_needed (mctx, to_idx);
> }
>
>
>
>
>
>
>
>
>
> static Idx
>
> find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
> Idx subexp_idx, int type)
> {
> Idx cls_idx;
> for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx)
> {
> Idx cls_node = nodes->elems[cls_idx];
> const re_token_t *node = dfa->nodes + cls_node;
> if (node->type == type
> && node->opr.idx == subexp_idx)
> return cls_node;
> }
> return ((Idx) -1) ;
> }
>
>
>
>
>
>
> static reg_errcode_t
>
> check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
> Idx top_str, Idx last_node, Idx last_str, int type)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> reg_errcode_t err = _REG_NOERROR ;
> Idx subexp_num, backup_cur_idx, str_idx, null_cnt;
> re_dfastate_t *cur_state = 0 ;
> re_node_set *cur_nodes, next_nodes;
> re_dfastate_t **backup_state_log;
> unsigned int context;
>
> subexp_num = dfa->nodes[top_node].opr.idx;
>
> if (( path->alloc < last_str + mctx->max_mb_elem_len + 1 ) )
> {
> re_dfastate_t **new_array;
> Idx old_alloc = path->alloc;
> Idx new_alloc = old_alloc + last_str + mctx->max_mb_elem_len + 1;
> if (( new_alloc < old_alloc )
> || ( 4294967295U / sizeof (re_dfastate_t *) < new_alloc ) )
> return _REG_ESPACE ;
> new_array = (( re_dfastate_t * *) realloc ( path->array , (
new_alloc ) * sizeof ( re_dfastate_t * ))) ;
> if (( new_array == 0 ) )
> return _REG_ESPACE ;
> path->array = new_array;
> path->alloc = new_alloc;
> memset (new_array + old_alloc, '\0',
> sizeof (re_dfastate_t *) * (path->alloc - old_alloc));
> }
>
> str_idx = path->next_idx ? path->next_idx : top_str;
>
>
> backup_state_log = mctx->state_log;
> backup_cur_idx = mctx->input.cur_idx;
> mctx->state_log = path->array;
> mctx->input.cur_idx = str_idx;
>
>
> context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
> if (str_idx == top_str)
> {
> err = re_node_set_init_1 (&next_nodes, top_node);
> if (( err != _REG_NOERROR ) )
> return err;
> err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &next_nodes )->elems ) ;
> return err;
> }
> }
> else
> {
> cur_state = mctx->state_log[str_idx];
> if (cur_state && cur_state->has_backref)
> {
> err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> else
> memset ( &next_nodes , '\0', sizeof (re_node_set)) ;
> }
> if (str_idx == top_str || (cur_state && cur_state->has_backref))
> {
> if (next_nodes.nelem)
> {
> err = expand_bkref_cache (mctx, &next_nodes, str_idx,
> subexp_num, type);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &next_nodes )->elems ) ;
> return err;
> }
> }
> cur_state = re_acquire_state_context (&err, dfa, &next_nodes,
context);
> if (( cur_state == 0 && err != _REG_NOERROR ) )
> {
> free ( ( &next_nodes )->elems ) ;
> return err;
> }
> mctx->state_log[str_idx] = cur_state;
> }
>
> for (null_cnt = 0; str_idx < last_str && null_cnt <=
mctx->max_mb_elem_len;)
> {
> (( &next_nodes )->nelem = 0) ;
> if (mctx->state_log[str_idx + 1])
> {
> err = re_node_set_merge (&next_nodes,
> &mctx->state_log[str_idx + 1]->nodes);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &next_nodes )->elems ) ;
> return err;
> }
> }
> if (cur_state)
> {
> err = check_arrival_add_next_nodes (mctx, str_idx,
> &cur_state->non_eps_nodes,
> &next_nodes);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &next_nodes )->elems ) ;
> return err;
> }
> }
> ++str_idx;
> if (next_nodes.nelem)
> {
> err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &next_nodes )->elems ) ;
> return err;
> }
> err = expand_bkref_cache (mctx, &next_nodes, str_idx,
> subexp_num, type);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &next_nodes )->elems ) ;
> return err;
> }
> }
> context = re_string_context_at (&mctx->input, str_idx - 1,
mctx->eflags);
> cur_state = re_acquire_state_context (&err, dfa, &next_nodes,
context);
> if (( cur_state == 0 && err != _REG_NOERROR ) )
> {
> free ( ( &next_nodes )->elems ) ;
> return err;
> }
> mctx->state_log[str_idx] = cur_state;
> null_cnt = cur_state == 0 ? null_cnt + 1 : 0;
> }
> free ( ( &next_nodes )->elems ) ;
> cur_nodes = (mctx->state_log[last_str] == 0 ? 0
> : &mctx->state_log[last_str]->nodes);
> path->next_idx = str_idx;
>
>
> mctx->state_log = backup_state_log;
> mctx->input.cur_idx = backup_cur_idx;
>
>
> if (cur_nodes != 0 && re_node_set_contains (cur_nodes, last_node))
> return _REG_NOERROR ;
>
> return _REG_NOMATCH ;
> }
>
>
>
>
>
>
>
>
>
> static reg_errcode_t
>
> check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
> re_node_set *cur_nodes, re_node_set *next_nodes)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> _Bool ok;
> Idx cur_idx;
> reg_errcode_t err = _REG_NOERROR ;
> re_node_set union_set;
> memset ( &union_set , '\0', sizeof (re_node_set)) ;
> for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
> {
> int naccepted = 0;
> Idx cur_node = cur_nodes->elems[cur_idx];
>
>
>
>
> # 3129 "regexec.c"
>
> if (naccepted
> || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
> {
> ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
> if (( ! ok ) )
> {
> free ( ( &union_set )->elems ) ;
> return _REG_ESPACE ;
> }
> }
> }
> free ( ( &union_set )->elems ) ;
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
>
> static reg_errcode_t
>
> check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
> Idx ex_subexp, int type)
> {
> reg_errcode_t err;
> Idx idx, outside_node;
> re_node_set new_nodes;
>
>
>
> err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
> if (( err != _REG_NOERROR ) )
> return err;
>
>
>
> for (idx = 0; idx < cur_nodes->nelem; ++idx)
> {
> Idx cur_node = cur_nodes->elems[idx];
> const re_node_set *eclosure = dfa->eclosures + cur_node;
> outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type);
> if (outside_node == ((Idx) -1) )
> {
>
> err = re_node_set_merge (&new_nodes, eclosure);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &new_nodes )->elems ) ;
> return err;
> }
> }
> else
> {
>
> err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
> ex_subexp, type);
> if (( err != _REG_NOERROR ) )
> {
> free ( ( &new_nodes )->elems ) ;
> return err;
> }
> }
> }
> free ( ( cur_nodes )->elems ) ;
> *cur_nodes = new_nodes;
> return _REG_NOERROR ;
> }
>
>
>
>
>
> static reg_errcode_t
>
> check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
> Idx target, Idx ex_subexp, int type)
> {
> Idx cur_node;
> for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);)
> {
> _Bool ok;
>
> if (dfa->nodes[cur_node].type == type
> && dfa->nodes[cur_node].opr.idx == ex_subexp)
> {
> if (type == OP_CLOSE_SUBEXP)
> {
> ok = re_node_set_insert (dst_nodes, cur_node);
> if (( ! ok ) )
> return _REG_ESPACE ;
> }
> break;
> }
> ok = re_node_set_insert (dst_nodes, cur_node);
> if (( ! ok ) )
> return _REG_ESPACE ;
> if (dfa->edests[cur_node].nelem == 0)
> break;
> if (dfa->edests[cur_node].nelem == 2)
> {
> reg_errcode_t err;
> err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
> dfa->edests[cur_node].elems[1],
> ex_subexp, type);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> cur_node = dfa->edests[cur_node].elems[0];
> }
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
> static reg_errcode_t
>
> expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
> Idx cur_str, Idx subexp_num, int type)
> {
> const re_dfa_t *const dfa = mctx->dfa;
> reg_errcode_t err;
> Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
> struct re_backref_cache_entry *ent;
>
> if (cache_idx_start == ((Idx) -1) )
> return _REG_NOERROR ;
>
> restart:
> ent = mctx->bkref_ents + cache_idx_start;
> do
> {
> Idx to_idx, next_node;
>
>
> if (!re_node_set_contains (cur_nodes, ent->node))
> continue;
>
> to_idx = cur_str + ent->subexp_to - ent->subexp_from;
>
>
> if (to_idx == cur_str)
> {
>
>
> re_node_set new_dests;
> reg_errcode_t err2, err3;
> next_node = dfa->edests[ent->node].elems[0];
> if (re_node_set_contains (cur_nodes, next_node))
> continue;
> err = re_node_set_init_1 (&new_dests, next_node);
> err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
> err3 = re_node_set_merge (cur_nodes, &new_dests);
> free ( ( &new_dests )->elems ) ;
> if (( err != _REG_NOERROR || err2 != _REG_NOERROR
> || err3 != _REG_NOERROR ) )
> {
> err = (err != _REG_NOERROR ? err
> : (err2 != _REG_NOERROR ? err2 : err3));
> return err;
> }
>
> goto restart;
> }
> else
> {
> re_node_set union_set;
> next_node = dfa->nexts[ent->node];
> if (mctx->state_log[to_idx])
> {
> _Bool ok;
> if (re_node_set_contains (&mctx->state_log[to_idx]->nodes,
> next_node))
> continue;
> err = re_node_set_init_copy (&union_set,
> &mctx->state_log[to_idx]->nodes);
> ok = re_node_set_insert (&union_set, next_node);
> if (( err != _REG_NOERROR || ! ok ) )
> {
> free ( ( &union_set )->elems ) ;
> err = err != _REG_NOERROR ? err : _REG_ESPACE ;
> return err;
> }
> }
> else
> {
> err = re_node_set_init_1 (&union_set, next_node);
> if (( err != _REG_NOERROR ) )
> return err;
> }
> mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
> free ( ( &union_set )->elems ) ;
> if (( mctx->state_log[to_idx] == 0
> && err != _REG_NOERROR ) )
> return err;
> }
> }
> while (ent++->more);
> return _REG_NOERROR ;
> }
>
>
>
>
> static _Bool
>
> build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
> {
> reg_errcode_t err;
> Idx i, j;
> int ch;
> _Bool need_word_trtable = 0 ;
> bitset_word_t elem, mask;
> _Bool dests_node_malloced = 0 ;
> _Bool dest_states_malloced = 0 ;
> Idx ndests;
> re_dfastate_t **trtable;
> re_dfastate_t **dest_states = 0 , **dest_states_word, **dest_states_nl;
> re_node_set follows, *dests_node;
> bitset_t *dests_ch;
> bitset_t acceptable;
>
> struct dests_alloc
> {
> re_node_set dests_node[(0xff + 1) ];
> bitset_t dests_ch[(0xff + 1) ];
> } *dests_alloc;
>
>
>
>
>
> if ((( sizeof (struct dests_alloc) ) < 4032) )
> dests_alloc = (struct dests_alloc *) __builtin_alloca (sizeof
(struct dests_alloc));
> else
> {
> dests_alloc = (( struct dests_alloc *) malloc (( 1 ) * sizeof (
struct dests_alloc ))) ;
> if (( dests_alloc == 0 ) )
> return 0 ;
> dests_node_malloced = 1 ;
> }
> dests_node = dests_alloc->dests_node;
> dests_ch = dests_alloc->dests_ch;
>
>
> state->word_trtable = state->trtable = 0 ;
>
>
>
> ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
> if (( ! ((Idx) (( ndests ) - 1) < (Idx) (((Idx) -2) - 1)) ) )
> {
> if (dests_node_malloced)
> free (dests_alloc);
> if (ndests == 0)
> {
> state->trtable = (re_dfastate_t **)
> calloc (sizeof (re_dfastate_t *), (0xff + 1) );
> return 1 ;
> }
> return 0 ;
> }
>
> err = re_node_set_alloc (&follows, ndests + 1);
> if (( err != _REG_NOERROR ) )
> goto out_free;
>
>
> if (( (((4294967295U - (sizeof (re_node_set) + sizeof (bitset_t)) *
(0xff + 1) )
> / (3 * sizeof (re_dfastate_t *)))
> < ndests) ) )
>
> goto out_free;
>
> if ((( (sizeof (re_node_set) + sizeof (bitset_t)) * (0xff + 1)
> + ndests * 3 * sizeof (re_dfastate_t *) ) < 4032) )
> dest_states = (re_dfastate_t **)
> __builtin_alloca (ndests * 3 * sizeof (re_dfastate_t *));
> else
> {
> dest_states = (re_dfastate_t **)
> malloc (ndests * 3 * sizeof (re_dfastate_t *));
> if (( dest_states == 0 ) )
> {
> out_free:
> if (dest_states_malloced)
> free (dest_states);
> free ( ( &follows )->elems ) ;
> for (i = 0; i < ndests; ++i)
> free ( ( dests_node + i )->elems ) ;
> if (dests_node_malloced)
> free (dests_alloc);
> return 0 ;
> }
> dest_states_malloced = 1 ;
> }
> dest_states_word = dest_states + ndests;
> dest_states_nl = dest_states_word + ndests;
> bitset_empty (acceptable);
>
>
> for (i = 0; i < ndests; ++i)
> {
> Idx next_node;
> (( &follows )->nelem = 0) ;
>
> for (j = 0; j < dests_node[i].nelem; ++j)
> {
> next_node = dfa->nexts[dests_node[i].elems[j]];
> if (next_node != ((Idx) -1) )
> {
> err = re_node_set_merge (&follows, dfa->eclosures + next_node);
> if (( err != _REG_NOERROR ) )
> goto out_free;
> }
> }
> dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
> if (( dest_states[i] == 0 && err != _REG_NOERROR ) )
> goto out_free;
>
>
> if (dest_states[i]->has_constraint)
> {
> dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
> 1 );
> if (( dest_states_word[i] == 0 && err != _REG_NOERROR ) )
> goto out_free;
>
> if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
> need_word_trtable = 1 ;
>
> dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
> (1 << 1) );
> if (( dest_states_nl[i] == 0 && err != _REG_NOERROR ) )
> goto out_free;
> }
> else
> {
> dest_states_word[i] = dest_states[i];
> dest_states_nl[i] = dest_states[i];
> }
> bitset_merge (acceptable, dests_ch[i]);
> }
>
> if (! ( need_word_trtable ) )
> {
>
>
>
>
> trtable = state->trtable =
> (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), (0xff + 1) );
> if (( trtable == 0 ) )
> goto out_free;
>
>
> for (i = 0; i < (((0xff + 1) + 32 - 1) / 32 ) ; ++i)
> for (ch = i * 32 , elem = acceptable[i], mask = 1;
> elem;
> mask <<= 1, elem >>= 1, ++ch)
> if (( elem & 1 ) )
> {
>
>
> for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
> ;
>
>
> if (dfa->word_char[i] & mask)
> trtable[ch] = dest_states_word[j];
> else
> trtable[ch] = dest_states[j];
> }
> }
> else
> {
>
>
>
>
>
> trtable = state->word_trtable =
> (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * (0xff + 1) );
> if (( trtable == 0 ) )
> goto out_free;
>
>
> for (i = 0; i < (((0xff + 1) + 32 - 1) / 32 ) ; ++i)
> for (ch = i * 32 , elem = acceptable[i], mask = 1;
> elem;
> mask <<= 1, elem >>= 1, ++ch)
> if (( elem & 1 ) )
> {
>
>
> for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
> ;
>
>
> trtable[ch] = dest_states[j];
> trtable[ch + (0xff + 1) ] = dest_states_word[j];
> }
> }
>
>
> if (bitset_contain (acceptable, '\n' ))
> {
>
> for (j = 0; j < ndests; ++j)
> if (bitset_contain (dests_ch[j], '\n' ))
> {
>
> trtable['\n' ] = dest_states_nl[j];
> if (need_word_trtable)
> trtable['\n' + (0xff + 1) ] = dest_states_nl[j];
>
>
> break;
> }
> }
>
> if (dest_states_malloced)
> free (dest_states);
>
> free ( ( &follows )->elems ) ;
> for (i = 0; i < ndests; ++i)
> free ( ( dests_node + i )->elems ) ;
>
> if (dests_node_malloced)
> free (dests_alloc);
>
> return 1 ;
> }
>
>
>
>
>
>
> static Idx
>
> group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t
*state,
> re_node_set *dests_node, bitset_t *dests_ch)
> {
> reg_errcode_t err;
> _Bool ok;
> Idx i, j, k;
> Idx ndests;
> bitset_t accepts;
> const re_node_set *cur_nodes = &state->nodes;
> bitset_empty (accepts);
> ndests = 0;
>
>
> for (i = 0; i < cur_nodes->nelem; ++i)
> {
> re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
> re_token_type_t type = node->type;
> unsigned int constraint = node->constraint;
>
>
> if (type == CHARACTER)
> bitset_set (accepts, node->opr.c);
> else if (type == SIMPLE_BRACKET)
> {
> bitset_merge (accepts, node->opr.sbcset);
> }
> else if (type == OP_PERIOD)
> {
>
>
>
>
>
> bitset_set_all (accepts);
> if (!(dfa->syntax & ((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) ))
> bitset_clear (accepts, '\n');
> if (dfa->syntax & (((((((((unsigned long int) 1) << 1) << 1)
<< 1) << 1) << 1) << 1) << 1) )
> bitset_clear (accepts, '\0');
> }
> # 3626 "regexec.c"
>
> else
> continue;
>
>
>
> if (constraint)
> {
> if (constraint & 0x0020 )
> {
> _Bool accepts_newline = bitset_contain (accepts, '\n' );
> bitset_empty (accepts);
> if (accepts_newline)
> bitset_set (accepts, '\n' );
> else
> continue;
> }
> if (constraint & 0x0080 )
> {
> bitset_empty (accepts);
> continue;
> }
>
> if (constraint & 0x0004 )
> {
> bitset_word_t any_set = 0;
> if (type == CHARACTER && !node->word_char)
> {
> bitset_empty (accepts);
> continue;
> }
>
>
>
>
>
>
> for (j = 0; j < (((0xff + 1) + 32 - 1) / 32 ) ; ++j)
> any_set |= (accepts[j] &= dfa->word_char[j]);
> if (!any_set)
> continue;
> }
> if (constraint & 0x0008 )
> {
> bitset_word_t any_set = 0;
> if (type == CHARACTER && node->word_char)
> {
> bitset_empty (accepts);
> continue;
> }
>
>
>
>
>
>
> for (j = 0; j < (((0xff + 1) + 32 - 1) / 32 ) ; ++j)
> any_set |= (accepts[j] &= ~dfa->word_char[j]);
> if (!any_set)
> continue;
> }
> }
>
>
>
> for (j = 0; j < ndests; ++j)
> {
> bitset_t intersec;
> bitset_t remains;
>
> bitset_word_t has_intersec, not_subset, not_consumed;
>
>
> if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c))
> continue;
>
>
> has_intersec = 0;
> for (k = 0; k < (((0xff + 1) + 32 - 1) / 32 ) ; ++k)
> has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k];
>
> if (!has_intersec)
> continue;
>
>
> not_subset = not_consumed = 0;
> for (k = 0; k < (((0xff + 1) + 32 - 1) / 32 ) ; ++k)
> {
> not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k];
> not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k];
> }
>
>
>
> if (not_subset)
> {
> bitset_copy (dests_ch[ndests], remains);
> bitset_copy (dests_ch[j], intersec);
> err = re_node_set_init_copy (dests_node + ndests,
&dests_node[j]);
> if (( err != _REG_NOERROR ) )
> goto error_return;
> ++ndests;
> }
>
>
> ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
> if (( ! ok ) )
> goto error_return;
>
>
> if (!not_consumed)
> break;
> }
>
> if (j == ndests)
> {
> bitset_copy (dests_ch[ndests], accepts);
> err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
> if (( err != _REG_NOERROR ) )
> goto error_return;
> ++ndests;
> bitset_empty (accepts);
> }
> }
> return ndests;
> error_return:
> for (j = 0; j < ndests; ++j)
> free ( ( dests_node + j )->elems ) ;
> return ((Idx) -1) ;
> }
>
> # 4061 "regexec.c"
>
>
>
>
>
> static _Bool
>
> check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
> Idx idx)
> {
> unsigned char ch;
> ch = (( &mctx->input )->mbs[ idx ]) ;
> switch (node->type)
> {
> case CHARACTER:
> if (node->opr.c != ch)
> return 0 ;
> break;
>
> case SIMPLE_BRACKET:
> if (!bitset_contain (node->opr.sbcset, ch))
> return 0 ;
> break;
>
>
>
>
>
>
>
> case OP_PERIOD:
> if ((ch == '\n' && !(mctx->dfa->syntax & ((((((((unsigned long
int) 1) << 1) << 1) << 1) << 1) << 1) << 1) ))
> || (ch == '\0' && (mctx->dfa->syntax & (((((((((unsigned long
int) 1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) )))
> return 0 ;
> break;
>
> default:
> return 0 ;
> }
>
> if (node->constraint)
> {
>
>
> unsigned int context = re_string_context_at (&mctx->input, idx,
> mctx->eflags);
> if ((((( node->constraint ) & 0x0004 ) && ! (( context ) & 1 )
) || ((( node->constraint ) & 0x0008 ) && (( context ) & 1 ) ) || (((
node->constraint ) & 0x0020 ) && ! (( context ) & (1 << 1) ) ) ||
((( node->constraint ) & 0x0080 ) && ! (( context ) & (((1 << 1) <<
1) << 1) ) )) )
> return 0 ;
> }
>
> return 1 ;
> }
>
>
>
> static reg_errcode_t
>
> extend_buffers (re_match_context_t *mctx)
> {
> reg_errcode_t ret;
> re_string_t *pstr = &mctx->input;
>
>
> if (( 4294967295U / 2 / sizeof (re_dfastate_t *) <= pstr->bufs_len ) )
> return _REG_ESPACE ;
>
>
> ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
> if (( ret != _REG_NOERROR ) )
> return ret;
>
> if (mctx->state_log != 0 )
> {
>
>
>
>
> re_dfastate_t **new_array = (( re_dfastate_t * *) realloc (
mctx->state_log , (
> pstr->bufs_len + 1 ) * sizeof (
re_dfastate_t * ))) ;
> if (( new_array == 0 ) )
> return _REG_ESPACE ;
> mctx->state_log = new_array;
> }
>
>
> if (pstr->icase)
> {
> # 4156 "regexec.c"
>
> build_upper_buffer (pstr);
> }
> else
> {
>
>
>
>
>
> {
> if (pstr->trans != 0 )
> re_string_translate_buffer (pstr);
> }
> }
> return _REG_NOERROR ;
> }
>
>
>
>
>
>
> static reg_errcode_t
>
> match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
> {
> mctx->eflags = eflags;
> mctx->match_last = ((Idx) -1) ;
> if (n > 0)
> {
>
> size_t max_object_size =
> (( sizeof (struct re_backref_cache_entry) ) < (
> sizeof (re_sub_match_top_t *) ) ? ( sizeof
(re_sub_match_top_t *) ) : ( sizeof (struct re_backref_cache_entry) )) ;
> if (( 4294967295U / max_object_size < n ) )
> return _REG_ESPACE ;
>
> mctx->bkref_ents = (( struct re_backref_cache_entry *) malloc
(( n ) * sizeof ( struct re_backref_cache_entry ))) ;
> mctx->sub_tops = (( re_sub_match_top_t * *) malloc (( n ) *
sizeof ( re_sub_match_top_t * ))) ;
> if (( mctx->bkref_ents == 0 || mctx->sub_tops == 0 ) )
> return _REG_ESPACE ;
> }
>
>
>
>
>
> mctx->abkref_ents = n;
> mctx->max_mb_elem_len = 1;
> mctx->asub_tops = n;
> return _REG_NOERROR ;
> }
>
>
>
>
>
> static void
>
> match_ctx_clean (re_match_context_t *mctx)
> {
> Idx st_idx;
> for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
> {
> Idx sl_idx;
> re_sub_match_top_t *top = mctx->sub_tops[st_idx];
> for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx)
> {
> re_sub_match_last_t *last = top->lasts[sl_idx];
> free ( last->path.array ) ;
> free ( last ) ;
> }
> free ( top->lasts ) ;
> if (top->path)
> {
> free ( top->path->array ) ;
> free ( top->path ) ;
> }
> free (top);
> }
>
> mctx->nsub_tops = 0;
> mctx->nbkref_ents = 0;
> }
>
>
>
> static void
>
> match_ctx_free (re_match_context_t *mctx)
> {
>
> match_ctx_clean (mctx);
> free ( mctx->sub_tops ) ;
> free ( mctx->bkref_ents ) ;
> }
>
>
>
>
>
>
> static reg_errcode_t
>
> match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx,
Idx from,
> Idx to)
> {
> if (mctx->nbkref_ents >= mctx->abkref_ents)
> {
> struct re_backref_cache_entry* new_entry;
> new_entry = (( struct re_backref_cache_entry *) realloc (
mctx->bkref_ents , (
> mctx->abkref_ents * 2 ) * sizeof ( struct
re_backref_cache_entry ))) ;
> if (( new_entry == 0 ) )
> {
> free ( mctx->bkref_ents ) ;
> return _REG_ESPACE ;
> }
> mctx->bkref_ents = new_entry;
> memset (mctx->bkref_ents + mctx->nbkref_ents, '\0',
> sizeof (struct re_backref_cache_entry) * mctx->abkref_ents);
> mctx->abkref_ents *= 2;
> }
> if (mctx->nbkref_ents > 0
> && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx)
> mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1;
>
> mctx->bkref_ents[mctx->nbkref_ents].node = node;
> mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx;
> mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from;
> mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to;
>
>
>
>
>
>
>
>
>
> mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map
> = (from == to ? -1 : 0);
>
> mctx->bkref_ents[mctx->nbkref_ents++].more = 0;
> if (mctx->max_mb_elem_len < to - from)
> mctx->max_mb_elem_len = to - from;
> return _REG_NOERROR ;
> }
>
>
>
>
> static Idx
>
> search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
> {
> Idx left, right, mid, last;
> last = right = mctx->nbkref_ents;
> for (left = 0; left < right;)
> {
> mid = (left + right) / 2;
> if (mctx->bkref_ents[mid].str_idx < str_idx)
> left = mid + 1;
> else
> right = mid;
> }
> if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
> return left;
> else
> return ((Idx) -1) ;
> }
>
>
>
>
> static reg_errcode_t
>
> match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
> {
>
>
>
>
> if (( mctx->nsub_tops == mctx->asub_tops ) )
> {
> Idx new_asub_tops = mctx->asub_tops * 2;
> re_sub_match_top_t **new_array = ((
> re_sub_match_top_t * *) realloc (
mctx->sub_tops , (
> new_asub_tops ) * sizeof
( re_sub_match_top_t * ))) ;
> if (( new_array == 0 ) )
> return _REG_ESPACE ;
> mctx->sub_tops = new_array;
> mctx->asub_tops = new_asub_tops;
> }
> mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof
(re_sub_match_top_t));
> if (( mctx->sub_tops[mctx->nsub_tops] == 0 ) )
> return _REG_ESPACE ;
> mctx->sub_tops[mctx->nsub_tops]->node = node;
> mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
> return _REG_NOERROR ;
> }
>
>
>
>
> static re_sub_match_last_t *
>
> match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
> {
> re_sub_match_last_t *new_entry;
> if (( subtop->nlasts == subtop->alasts ) )
> {
> Idx new_alasts = 2 * subtop->alasts + 1;
> re_sub_match_last_t **new_array = ((
> re_sub_match_last_t * *) realloc (
subtop->lasts , (
> new_alasts ) * sizeof
( re_sub_match_last_t * ))) ;
> if (( new_array == 0 ) )
> return 0 ;
> subtop->lasts = new_array;
> subtop->alasts = new_alasts;
> }
> new_entry = calloc (1, sizeof (re_sub_match_last_t));
> if (( new_entry != 0 ) )
> {
> subtop->lasts[subtop->nlasts] = new_entry;
> new_entry->node = node;
> new_entry->str_idx = str_idx;
> ++subtop->nlasts;
> }
> return new_entry;
> }
>
> static void
>
> sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
> re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx)
> {
> sctx->sifted_states = sifted_sts;
> sctx->limited_states = limited_sts;
> sctx->last_node = last_node;
> sctx->last_str_idx = last_str_idx;
> memset ( &sctx->limits , '\0', sizeof (re_node_set)) ;
> }
> # 64 "regex.c" 2
>
>
>
>
>
>
>
>
>
>
>
>
> %
- --
Derek R. Price
CVS Solutions Architect
Get CVS support at Ximbiot <http://ximbiot.com>!
v: +1 248.835.1260
f: +1 248.835.1263
<mailto:address@hidden>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEPo3uLD1OTBfyMaQRAtWqAJoD8Ib7OzQRo/YUyPOkgi6fcTzsxgCgmD1b
jdyzcrvjKqCJacmFs8utQt8=
=poMc
-----END PGP SIGNATURE-----
- regex module broken (was Re: cvs TRUNK broken for FreeBSD 4.11-RELEASE-p11),
Derek R. Price <=